package cn.fl.product.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cmm.comm.facade.framework.condition.SysCtrlCfgQueryCondition;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.fl.system.service.ISysCtrlCfgService;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.spl.facade.lnkcomp.constant.PrjLnkCompRelInfoConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.comm.facade.upload.api.IUploadApiService;
import cmm.comm.facade.upload.condition.SysUlDatCfgQueryCondition;
import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.comm.facade.upload.dto.SysUlDatCfgDTO;
import cmm.comm.facade.upload.dto.SysUlDatCfgDtlDTO;
import cmm.comm.facade.upload.dto.SysUlFilesRecDTO;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.constant.SysOrgConstant;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.bizflow.vo.SysBizFlowRlVO;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.customer.vo.CstValidCardInfoVO;
import cn.fl.flow.service.IFlowService;
import cn.fl.framework.base.constant.WebBaseConstant;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.hsj.service.IHsjQueryService;
import cn.fl.product.service.ISplBscInfoApplyService;
import cn.fl.product.service.ISplInfoService;
import cn.fl.product.service.ISplRlPsnService;
import cn.fl.product.transform.SplInfoVOTransform;
import cn.fl.product.vo.SplBiApplyFlowRlVO;
import cn.fl.product.vo.SplBiApplyRlPsnVO;
import cn.fl.product.vo.SplBscInfoApplyVO;
import cn.fl.product.vo.SplInfoVO;
import cn.fl.product.vo.SplRlPsnVO;
import cn.fl.project.service.ILnkCompModService;
import cn.fl.project.service.IPrjLnkCompApplyService;
import cn.fl.project.vo.PrjFileInfoVO;
import cn.fl.spl.service.ISplOpLogRecService;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysUlFilesRecService;
import cn.fl.system.vo.SysFlowManageVVO;
import cn.fl.system.vo.SysUlFilesRecVO;
import cn.fl.upload.constant.UploadConstant;
import fl.customer.facade.customer.constant.CustomerConstant;
import fl.flow.facade.flow.api.IFlowApiService;
import fl.flow.facade.flow.condition.SysFlowManageVQueryCondition;
import fl.flow.facade.flow.condition.SysFlowSHQueryCondition;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.FlowStartParamsDTO;
import fl.flow.facade.flow.dto.FlowStartedDTO;
import fl.flow.facade.flow.dto.SysFlowSHDTO;
import fl.spl.facade.bizflow.condition.SysBizFlowRlQC;
import fl.spl.facade.bizflow.constant.SysBizFlowRlConstant;
import fl.spl.facade.crm.api.ISplDataStatisticsApiService;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.SplInfoFileCfgEnum;
import fl.spl.facade.lnkcomp.condition.LnkCompModQC;
import fl.spl.facade.framework.enums.SplRelLogBizTypCdNum;
import fl.spl.facade.framework.enums.SplRelLogOpTypCdNum;
import fl.spl.facade.spl.condition.SplBscInfoApplyQC;
import fl.spl.facade.spl.condition.SplInfoQueryCondition;
import fl.spl.facade.spl.condition.SplRlPsnQueryCondition;
import fl.spl.facade.spl.constant.SplInfoConstant;
import net.sf.json.JSONArray;
import tc.relationmap.facade.relationmap.hsj.dto.HsjBasicDTO;

/**
 * @Description: 供应商信息表 控制层
 */
@Controller
@RequestMapping("/product/splApplyInfo")
public class SplInfoApplyController extends BaseController {

    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService;

    @Autowired
    private ISplBscInfoApplyService splBscInfoApplyService;

    @Autowired
    private ISysUlFilesRecService sysUlFilesRecService;

    @Autowired
    private ISplOpLogRecService splOpLogRecService;

    @Autowired
    private IUploadApiService uploadApiService ;
    
    @Autowired
    private ISplInfoService splInfoService ;
    
    @Autowired
    private ISplRlPsnService splRlPsnService ;
    
    @Autowired
	private IHsjQueryService hsjQueryService ;
    
    @Autowired
    private IFlowService flowService ;
    
    @Autowired
    private IPrjLnkCompApplyService prjLnkCompApplyService ;
    
    @Autowired
    private ISplDataStatisticsApiService splDataStatisticsApiService ;

    @Autowired
    private ILnkCompModService lnkCompModService ;

    @Autowired
    private IFlowApiService flowApiService ;

    @Autowired
    private ISysCtrlCfgService sysCtrlCfgService;


    /**
     * 到变更页面
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/toModifyPage.do", method = {RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = new ModelAndView("product/splInfo/prdSplInfoModify");
        String id = request.getParameter("id");
        String applyId = request.getParameter("applyId");
        String mfrId = request.getParameter("mfrId");
        String splNm = request.getParameter("splNm");
        String lxxz = request.getParameter("lxxz");
        String prdmarks = request.getParameter("prdmarks");
        String bizLicNo = request.getParameter("bizLicNo");
        String splAttrCd = request.getParameter("splAttrCd");//供应商属性 add by zhaoyong
        String audStsCd = request.getParameter("audStsCd");//是否可编辑
        String taskNm = request.getParameter("taskNm");//流程节点名称
        String succ = request.getParameter("succ"); //统一社会信用代码
        String isApply = request.getParameter("isApply") ; //变更标识
        String flowType = request.getParameter("flowType");//变更流程类型 1：工商变更，0：基础变更  用来判断页面可修改字段
        try {
            if (StringUtils.isNotBlank(applyId) && StringUtils.isEmpty(id)) {
                SplBscInfoApplyVO vo = this.splBscInfoApplyService.getSplBscInfoApplyById(Long.valueOf(applyId), null);
                id = vo.getSplId() + "";
            }
            if (StringUtils.isNotEmpty(id)) {
                boolean auditStatus = this.splBscInfoApplyService.checkFlowStatus(Long.valueOf(id), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
                if (auditStatus) {
                    view.addObject("auditStatus", "1");
                } else {
                    view.addObject("auditStatus", "0");
                }
            }
            //专车供应商类型 jiangzg add 2017-7-31 16:21:51
            List<KeyValueVO> kvList = new ArrayList<>();
            List<SysDictionaryDTO> sysDictionaryDTOList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.SPL_TYP_GRP_CD);
            if (CollectionUtils.isNotEmpty(sysDictionaryDTOList)) {
                for (SysDictionaryDTO sysDictionaryDTO : sysDictionaryDTOList) {
                    KeyValueVO keyValueVO = new KeyValueVO();
                    keyValueVO.setKey(sysDictionaryDTO.getCode());
                    keyValueVO.setValue(sysDictionaryDTO.getCodeNm());
                    kvList.add(keyValueVO);
                }
            }

            view.addObject("searchSplTypCdList", JSONArray.fromObject(kvList.toArray()));
            view.addObject("currentBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
            view.addObject("id", id);
            view.addObject("applyId", applyId);
            view.addObject("splAttrCd", splAttrCd);
            view.addObject("mfrId", mfrId);
            view.addObject("splNm", splNm);
            view.addObject("lxxz", lxxz);
            view.addObject("prdmarks", prdmarks);
            view.addObject("bizLicNo", bizLicNo);
            view.addObject("succ",succ);
            view.addObject("isApply",isApply);
            view.addObject("currentUserId", CurrentThreadContext.getCurrentUserId());
            if(StringUtils.isNotEmpty(flowType)){
            	view.addObject("flowType", flowType);
            }else{
            	view.addObject("flowType", 0);
            }
            if (StringUtils.isBlank(audStsCd)) {
                audStsCd = "2";
            }
            view.addObject("audStsCd", audStsCd);

            //供应商流程呈报人节点传递此参数,控制供应商账号如果走的流程跟供应商是一个流程则允许修改
            String allowMdfBank = request.getParameter("allowMdfBank");
            view.addObject("allowMdfBank", allowMdfBank);
            String proIntId = request.getParameter("processInstanceId");//流程实例ID
            view.addObject("proIntId", proIntId);

            //获取下拉框选项
            //厂商
            List<KeyValueVO> mfrKVList = this.splBscInfoApplyService.searchMfrKVList();
            JSONArray mfrJson = JSONArray.fromObject(mfrKVList.toArray());
            view.addObject("mfrJson", mfrJson);

            //公司归属
            List<KeyValueVO> ownerKVList = this.splBscInfoApplyService.searchOwnerCdList();
            view.addObject("ownerKVList", JSON.toJSON(ownerKVList));

            //区域


            //万元美元
            List<KeyValueVO> capUntCdList = this.splBscInfoApplyService.searchCapUntCdList();
            view.addObject("capUntCdList", capUntCdList);
            //品牌
            List<KeyValueVO> tkBrCdList = this.splBscInfoApplyService.searchBrandList(DictionaryConstant.CODE_PRD_BR_CD_TK);
            List<KeyValueVO> carBrCdList = this.splBscInfoApplyService.searchBrandList(DictionaryConstant.CODE_PRD_BR_CD_CAR);
            List<KeyValueVO> busBrCdList = this.splBscInfoApplyService.searchBrandList(DictionaryConstant.CODE_PRD_BR_CD_BUS);



            JSONArray tkBrCdListJSON = JSONArray.fromObject(tkBrCdList.toArray());
            JSONArray carBrCdListJSON = JSONArray.fromObject(carBrCdList.toArray());
            JSONArray busBrCdListJSON = JSONArray.fromObject(busBrCdList.toArray());
            view.addObject("tkBrCdListJSON", tkBrCdListJSON);
            view.addObject("carBrCdListJSON", carBrCdListJSON);
            view.addObject("busBrCdListJSON", busBrCdListJSON);
            //经营类型
            List<KeyValueVO> searchNewCarTyp = this.splBscInfoApplyService.searchNewCarTyp();
            List<KeyValueVO> searchUsedCarTyp = this.splBscInfoApplyService.searchUsedCarTyp();
            view.addObject("newCarTypJSON", JSONArray.fromObject(searchNewCarTyp.toArray()));
            view.addObject("usedCarTypJSON", JSONArray.fromObject(searchUsedCarTyp.toArray()));
            //经营范围
            List<KeyValueVO> searchBizScopeTyp = this.splBscInfoApplyService.searchBizScopeTyp();
            view.addObject("bizScopeTypJSON",JSON.toJSON(searchBizScopeTyp));
            //企业性质
            List<KeyValueVO> corpTypCdList = this.splBscInfoApplyService.searchCorpTypCdList();
            view.addObject("corpTypCdList", corpTypCdList);
            //事业部
            List<KeyValueVO> searchBuOrgList = this.splBscInfoApplyService.searchBuOrgCdList();
            JSONArray buOrgCdsJson = JSONArray.fromObject(searchBuOrgList.toArray());
            view.addObject("buOrgCdsJson", buOrgCdsJson);
            //项目类型
            List<KeyValueVO> prjTypCdList = this.splBscInfoApplyService.searchPrjTypCdList();
            view.addObject("prjTypCdsJson", JSONArray.fromObject(prjTypCdList));
            //供应商级别
            List<KeyValueVO> splLvlCdList = this.splBscInfoApplyService.searchSplLvlCdList();
            view.addObject("splLvlCdList", splLvlCdList);
            List<KeyValueVO> prjLvlCdList = this.splBscInfoApplyService.searchPrjLvlCdList();
            view.addObject("prjLvlCdList", prjLvlCdList);


            //档案协议编号
            //view.addObject("fileNo",new Date().toString());
            SplInfoVO splInfoVO = null ;
            if (StringUtils.isNotBlank(id)) {
                splInfoVO = this.splBscInfoApplyService.selectSplInfoVOById(Long.valueOf(id));
                String mfrIdsString = splInfoVO.getMfrIdsString();
                String mfrNms = splInfoVO.getMfrNms();
                view.addObject("mfrIdsString", mfrIdsString);
                view.addObject("mfrNms", mfrNms);
                splAttrCd = splInfoVO.getSplAttrCd();
            }
            if (StringUtils.isEmpty(id)) {    //如果id为空,添加页面
                //获取当前登录人事业部
                String buOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
                int length = SysOrgConstant.SYS_ORG_CD_LENGTH * SysOrgConstant.SYS_BU_ORG_CD_LVL;
                if (buOrgCd.length() == length) {
                    view.addObject("buOrgCd", buOrgCd);
                }
            }
            view.addObject("currBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());

            //证件类型
            List<KeyValueVO> certTypCdList = this.splBscInfoApplyService.searchCertTypCdList();
            view.addObject("certTypCdListJSON", JSON.toJSON(certTypCdList));
            //联系人类型
            List<KeyValueVO> rlTypCDList = this.splBscInfoApplyService.searchRlTypCdList();
            view.addObject("rlTypCDListJSON", JSON.toJSON(rlTypCDList));

            //必填联系人类型
            List<SysDictionaryDTO> mustAddRlPsnTypCds = this.sysDictionaryApiService.searchGroupAll(CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(),DictionaryConstant.CODE_RL_TYP_CD);
            List<String> mustAddRlPsns = null ;
            List<String> noAddRlPsns = null ;
            if(CollectionUtils.isNotEmpty(mustAddRlPsnTypCds)){
                mustAddRlPsns = new ArrayList<>(mustAddRlPsnTypCds.size());
                noAddRlPsns = new ArrayList<>(mustAddRlPsnTypCds.size());
                for(SysDictionaryDTO dto : mustAddRlPsnTypCds){
                    if(BaseConstant.IS_YESNO_YES == dto.getIsSysDef()){
                        mustAddRlPsns.add(dto.getCode());
                    }else if(2 == dto.getIsSysDef()){
                        noAddRlPsns.add(dto.getCode());
                    }
                }
            }
            view.addObject("mustAddRlPsnTypCdJSON", null == mustAddRlPsns ? null :JSON.toJSON(mustAddRlPsns));
            view.addObject("noAddRlPsnTypCdJSON", null == noAddRlPsns ? null :JSON.toJSON(noAddRlPsns));

            String isShowAuditBtn = request.getParameter("isShowAuditBtn");
            view.addObject("isShowAuditBtn", isShowAuditBtn);

            view.addObject("currOrgCd", CurrentThreadContext.getCurrentOrgCd());
            view.addObject("currBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());

            //将流程权限信息赋值

            if(StringUtils.isNotEmpty(taskNm) && "信审中心审核".equals(taskNm)){
                view.addObject("isCheckVerify", 1);
            }else{
                view.addObject("isCheckVerify", 0);
            }

            //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
            //this.setBizFlowValue(view, request, id);


            //查询附件信息
            String cfgCd = null ;
            String tabNm = null ;
            String cfgOrgCd = null ;
            String cfgSysCd = null ;
            String modulePath = null;
            String rootPath = null ;
            String costomerPath = null ;
            String uploadSysCd = null ;
            if(StringUtils.isNotEmpty(splAttrCd)) {
                if (BaseConstant.IS_YESNO_YES_STR.equals(splAttrCd)) {
                    //自然人 附件查询
                    cfgCd = SplInfoFileCfgEnum.SPL021.getCode();
                    tabNm = SplInfoFileCfgEnum.SPL021.getTableNm();
                    cfgOrgCd = SplInfoFileCfgEnum.SPL021.getOrgCd();
                    cfgSysCd = SplInfoFileCfgEnum.SPL021.getSysCd();
                    modulePath = SplInfoFileCfgEnum.SPL021.getModulePath();
                    costomerPath = SplInfoFileCfgEnum.SPL021.getUploadCostomerPath();
                    rootPath = SplInfoFileCfgEnum.SPL021.getUploadRootPath();
                    uploadSysCd = SplInfoFileCfgEnum.SPL021.getUploadSysCd();
                } else {
                    //法人 附件查询
                    if(null != splInfoVO){
                        if (StringUtils.isNotEmpty(splInfoVO.getQualTypCd()) && BaseConstant.IS_YESNO_YES_STR.equals(splInfoVO.getQualTypCd())) {
                            //非三证合一
                            cfgCd = SplInfoFileCfgEnum.SPL020.getCode();
                            tabNm = SplInfoFileCfgEnum.SPL020.getTableNm();
                            cfgOrgCd = SplInfoFileCfgEnum.SPL020.getOrgCd();
                            cfgSysCd = SplInfoFileCfgEnum.SPL020.getSysCd();
                            modulePath = SplInfoFileCfgEnum.SPL020.getModulePath();
                            costomerPath = SplInfoFileCfgEnum.SPL020.getUploadCostomerPath();
                            rootPath = SplInfoFileCfgEnum.SPL020.getUploadRootPath();
                            uploadSysCd = SplInfoFileCfgEnum.SPL020.getUploadSysCd();
                        } else {
                            //三证合一
                            cfgCd = SplInfoFileCfgEnum.SPL019.getCode();
                            tabNm = SplInfoFileCfgEnum.SPL019.getTableNm();
                            cfgOrgCd = SplInfoFileCfgEnum.SPL019.getOrgCd();
                            cfgSysCd = SplInfoFileCfgEnum.SPL019.getSysCd();
                            modulePath = SplInfoFileCfgEnum.SPL019.getModulePath();
                            costomerPath = SplInfoFileCfgEnum.SPL019.getUploadCostomerPath();
                            rootPath = SplInfoFileCfgEnum.SPL019.getUploadRootPath();
                            uploadSysCd = SplInfoFileCfgEnum.SPL019.getUploadSysCd();
                        }
                    }
                }
            }
            view.addObject("tabNm", tabNm);
            view.addObject("cfgCd", cfgCd);
            view.addObject("cfgOrgCd", cfgOrgCd);
            view.addObject("cfgSysCd", cfgSysCd);
            view.addObject("modulePath", modulePath);
            view.addObject("costomerPath", costomerPath);
            view.addObject("rootPath", rootPath);
            view.addObject("uploadSysCd", uploadSysCd);
        } catch (BaseException ex) {
            BaseLogUtils.newWebLogger("跳转至变更页面失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            BaseLogUtils.newWebLogger("跳转至变更页面失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return view;
    }

    /**
     * 检查供应商主要流程信息是否变更
     */
    @RequestMapping(value = "/checkChangeSplInfo.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object checkChangeSplInfo(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        String applyId = request.getParameter("applyId");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
        SplInfoVO entity = new SplInfoVO();
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.newWebLogger("修改供应商信息,主键参数为空！.ID:" + id).setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
            return result;
        }
        try {
            result.setInfo("0");
            //经销商流程变更配置MAP
            Map<String,String> flowAuthMap = this.sysDictionaryApiService.searchGroupToMap(SplSystemConstant.SPL_SYS_CD,SplSystemConstant.DEFAULT_ORG_CD,SplSystemConstant.SPL_FLOW_AUTH_CONFIG_DIC_CD);
            if (StringUtils.isEmpty(applyId) && this.getChangeStatus(request,flowAuthMap)) {
                if (StringUtils.isNotEmpty(id)) {
                    String message = this.splBscInfoApplyService.getFlowMessage(Long.valueOf(id));
                    if (StringUtils.isNotBlank(message)) {
                        throw new BaseException(BaseExceptionConstant.COMMON_0001, "该供应商在" + message + "等事业部存在审核中流程，暂不能发起变更流程.");
                    }
                }
                result.setInfo("1");
                boolean auditStatus = this.splBscInfoApplyService.checkFlowStatus(Long.valueOf(id), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
                //主要信息发生变化，并该供应商存在审批中的变更流程
                if (auditStatus) {
                    result.setSuccess(BaseConstant.IS_YESNO_NO);
                    result.setInfo("该供应商已存在变更申请流程，不能重复发起变更！");
                    // 该供应商已存在变更申请流程，不能重复发起变更
                    return result;
                }
            }
            BaseLogUtils.newWebLogger("修改供应商数据成功.DATA:" + JSONObject.toJSONString(entity)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("修改供应商数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("修改供应商数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return result;
    }

    /**
     * 变更供应商信息
     */
    @RequestMapping(value = "/mdfInfoStartApplyFlow.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object modifySplInfoStartFlow(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        String applyId = request.getParameter("applyId");
        String fileParams = request.getParameter("fileParams");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
        SplInfoVO entity = new SplInfoVO();
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.newWebLogger("修改供应商信息,主键参数为空！.ID:" + id).setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
            return result;
        }
        try {

            //经销商ID
            Long splId = Long.valueOf(id);
            BaseLogUtils.newWebLogger("修改供应商信息,！.ID:" + id).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            //变更经销商数据ID
            Long applyInfoId =  StringUtils.isNotEmpty(applyId) ? Long.valueOf(applyId) : null ;
            BaseLogUtils.newWebLogger("修改供应商信息,！.applyInfoId:" + applyInfoId).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            //需发起变更流程，流程权限配置MAP
            Map<String,String> pDefKeyAndFlowNm = this.sysDictionaryApiService.searchGroupToMap(SplSystemConstant.SPL_SYS_CD,SplSystemConstant.DEFAULT_ORG_CD,SplSystemConstant.SPL_FLOW_AUTH_CONFIG_DIC_CD);
            BaseLogUtils.newWebLogger("修改供应商信息,！.pDefKeyAndFlowNm:" + JSON.toJSONString(pDefKeyAndFlowNm)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            //通过主键id 查询供应商信息
            SplInfoVO oldSplInfoVo = this.splBscInfoApplyService.selectSplInfoVOById(splId);
            BaseLogUtils.newWebLogger("修改供应商信息,！.oldSplInfoVo:" + JSON.toJSONString(oldSplInfoVo)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            //保存供应商基本信息
            this.toSaveBscApplyInfoVo(request, oldSplInfoVo , true);
            BaseLogUtils.newWebLogger("修改供应商信息！").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            //TODO 经销商变更基础信息 (可判断基础信息是否改变)
            SplBscInfoApplyVO bscApplyInfo = this.checkBscApplyInfo(request, oldSplInfoVo,applyInfoId);
            BaseLogUtils.newWebLogger("修改供应商信息,！.bscApplyInfo:" + JSON.toJSONString(bscApplyInfo)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            //TODO 查询联系人信息是否改变
            //获取原主要联系人信息
            SplRlPsnQueryCondition qc = new SplRlPsnQueryCondition();
            qc.setSplId(splId);
            List<SplRlPsnVO> SplRlPsnVOs = this.splBscInfoApplyService.searchSplRlPsnVOList(qc);
            BaseLogUtils.newWebLogger("修改供应商信息,！.SplRlPsnVOs:" + JSON.toJSONString(SplRlPsnVOs)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            Map map = this.checkBiApplyRlPsn(request, SplRlPsnVOs, applyInfoId);
            BaseLogUtils.newWebLogger("修改供应商信息,！.map:" + JSON.toJSONString(map)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            //是否变更
            Integer isChngBaseData = (Integer) map.get("isChngBaseData");
            BaseLogUtils.newWebLogger("修改供应商信息,！.isChngBaseData:" + JSON.toJSONString(isChngBaseData)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            //TODO 还可以优化 3、获取变更后的主要联系人信息
            List<SplBiApplyRlPsnVO> splBiApplyRlPsnVOS = (List<SplBiApplyRlPsnVO>) map.get("applyRlPsnVos");
            BaseLogUtils.newWebLogger("修改供应商信息,！.splBiApplyRlPsnVOS:" + JSON.toJSONString(splBiApplyRlPsnVOS)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            for (SplBiApplyRlPsnVO splBiApplyRlPsnVO : splBiApplyRlPsnVOS) {
                splBiApplyRlPsnVO.setBrPerVerify("2");
                splBiApplyRlPsnVO.setTdPerVerify("2");
                splBiApplyRlPsnVO.setBusInfoVerify("2");
                splBiApplyRlPsnVO.setPyPerVerify("2");
            }
            //4、保存重要联系人中非流程审核的参数
            this.saveBiApplyPsn(request, SplRlPsnVOs, splId);

            //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
           /* //TODO 查询流程权限信息是否改变
            List<SplBiApplyFlowRlVO> flowRlVOList = null;
            BaseLogUtils.info(logger, "modifySplInfoStartFlow", "修改供应商信息,！BuOrgCd:" + CurrentThreadContext.getCurrentBuOrgCd(), CurrentThreadContext.getCurrentUserName());
            if (SplBscInfoApplyConstant.SPL_ADMISSION_ORG_CD_0.equals(CurrentThreadContext.getCurrentBuOrgCd()) || SplBscInfoApplyConstant.SPL_ADMISSION_ORG_CD_05.equals(CurrentThreadContext.getCurrentBuOrgCd())) {
                //获取变更流程权限信息
                flowRlVOList = this.getApplyFlowRlVo(request,pDefKeyAndFlowNm);
                BaseLogUtils.info(logger, "modifySplInfoStartFlow", "修改供应商信息,！.flowRlVOList:" + JSON.toJSONString(flowRlVOList), CurrentThreadContext.getCurrentUserName());

            }*/

            //保存主要联系人基本信息和供应商信息
            //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
            /*if (CollectionUtils.isNotEmpty(flowRlVOList)) {
                bscApplyInfo.setIsChngLoanFlow(BaseConstant.IS_YESNO_YES);
            }*/
            if (BaseConstant.IS_YESNO_YES == isChngBaseData) {
                bscApplyInfo.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
                //保存基本信息
                this.splBscInfoApplyService.saveBscInfoApply(bscApplyInfo);
                //保存主要联系人
                this.splBscInfoApplyService.saveBiApplyRlPsn(splBiApplyRlPsnVOS, bscApplyInfo.getId());
            } else if (BaseConstant.IS_YESNO_YES == bscApplyInfo.getIsChngBaseData()) {
                //保存基本信息
                this.splBscInfoApplyService.saveBscInfoApply(bscApplyInfo);
            }

            //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
            //if (CollectionUtils.isNotEmpty(flowRlVOList)) {
                /*if (StringUtils.isEmpty(bscApplyInfo.getId())) {
                    //保存基本信息
                    this.splBscInfoApplyService.saveBscInfoApply(bscApplyInfo);
                }*/
                /*for(SplBiApplyFlowRlVO splBiApplyFlowRlVO : flowRlVOList){
                    splBiApplyFlowRlVO.setSplApplyId(bscApplyInfo.getId());
                    //TODO 需要改，批量插入
                    this.splBscInfoApplyService.saveSplApplyFlow(splBiApplyFlowRlVO);
                }*/
            //}


            //TODO 附件信息是否变更
            //附件信息变更
            boolean flag = false ;
            if(StringUtils.isNotEmpty(fileParams)){
                JSONArray arry = JSONArray.fromObject(fileParams);
                if (!(arry.size() > 0)) {
                    flag = false;
                }else{
                    flag = true;
                }
            }
            if(flag){
                if(StringUtils.isEmpty(bscApplyInfo.getId())){
                    //保存基本信息
                    this.splBscInfoApplyService.saveBscInfoApply(bscApplyInfo);
                }
            }

            //COPY 旧附件信息
            List<SysUlFilesRecVO> oldUlFilesRecVOList = null;
            if (StringUtils.isEmpty(applyId) && bscApplyInfo != null && flag) {
                SysUlFilesRecQueryCondition filesRecQueryCondition = new SysUlFilesRecQueryCondition();
                filesRecQueryCondition.setSysCd(SplSystemConstant.SPL_SYS_CD);
                filesRecQueryCondition.setIsDel(0);
                filesRecQueryCondition.setPkId(String.valueOf(bscApplyInfo.getSplId()));
                List<SysUlFilesRecVO> sysUlFilesRecVOs = this.sysUlFilesRecService.searchList(filesRecQueryCondition);
                if (CollectionUtils.isNotEmpty(sysUlFilesRecVOs)) {
                    oldUlFilesRecVOList = new ArrayList<>(sysUlFilesRecVOs.size());
                    //needAddOldRecVoList = new ArrayList<>(sysUlFilesRecVOs.size());
                    SysUlFilesRecVO vo = null;
                    for (SysUlFilesRecVO sysUlFilesRecVO : sysUlFilesRecVOs) {
                        vo = sysUlFilesRecVO;
                        //vo.setPkId(String.valueOf(splBscInfoApplyVO.getId())+"-HI");
                        vo.setId(null);
                        //needAddOldRecVoList.add(vo);
                        vo.setPkId(String.valueOf(bscApplyInfo.getId()));
                        oldUlFilesRecVOList.add(vo);
                    }
                }
            }
            BaseLogUtils.newWebLogger("修改供应商信息,！oldUlFilesRecVOList :" + oldUlFilesRecVOList == null ? "" : JSON.toJSONString(oldUlFilesRecVOList))
                    .setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            if (CollectionUtils.isNotEmpty(oldUlFilesRecVOList)) {
                this.sysUlFilesRecService.addSysUlFilesResList(oldUlFilesRecVOList);
            }

            String reason = request.getParameter("reason");// 操作原因

            //启动流程审核 保存文件信息
            if (BaseConstant.IS_YESNO_YES == bscApplyInfo.getIsChngBaseData() || BaseConstant.IS_YESNO_YES == bscApplyInfo.getIsChngLoanFlow() || flag) {
                //保存上传文件信息
                if(flag){
                    this.saveFlowSplFileList(request, bscApplyInfo.getId());
                }
                if (StringUtils.isEmpty(applyId)) {
                    //启动工作流信息
                    Map<String, Object> startParams = new HashMap<String, Object>();
                    startParams.put("isChngBaseData", bscApplyInfo.getIsChngBaseData());
                    startParams.put("isChngLoanFlow", bscApplyInfo.getIsChngLoanFlow());
//                    startParams.put("isFlowNumCount",this.splBscInfoApplyService.getFlowNumcount(Long.valueOf(applyId)));
                    try{
                        this.addFlowStart(request, Long.valueOf(id), bscApplyInfo.getId(), startParams);
                        BaseLogUtils.newWebLogger("修改供应商数据成功.DATA:" + JSONObject.toJSONString(entity)).setLogOperType(LogOperEnum.RESP)
                                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                                .setWarning(false)
                                .info();
                        // 启动流程成功,变更操作
                        try {
                            if (StringUtils.isNotEmpty(reason)) {
                                Long add = this.splOpLogRecService.add(id, reason, SplRelLogOpTypCdNum.APPLY.getOpTypCd(), SplRelLogBizTypCdNum.SPL.getBizTypCd());
                            }
                        } catch (BaseException e) {
                            BaseLogUtils.newWebLogger("插入供应商操作记录失败,业务异常").setLogOperType(LogOperEnum.REQ)
                                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                                    .setWarning(false)
                                    .setThrowable(e)
                                    .warn(LogExceptionEnum.COMMON_CODE_0002);
                        }
                    }catch (BaseException be){
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("供应商信息变更流程发起失败！");
                        if(flag){
                            SysUlFilesRecQueryCondition recQueryCondition = new SysUlFilesRecQueryCondition();
                            recQueryCondition.setPkId(String.valueOf(bscApplyInfo.getId()));
                            recQueryCondition.setIsDel(0);
                            this.sysUlFilesRecService.removeByCondition(recQueryCondition);
                        }
                    }catch (Exception e){
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("供应商信息变更流程发起失败！");
                        if(flag){
                            SysUlFilesRecQueryCondition recQueryCondition = new SysUlFilesRecQueryCondition();
                            recQueryCondition.setPkId(String.valueOf(bscApplyInfo.getId()));
                            recQueryCondition.setIsDel(0);
                            this.sysUlFilesRecService.removeByCondition(recQueryCondition);
                        }
                    }
                    /*FlowStartedDTO flowStartedDTO = this.addFlowStart(request, Long.valueOf(id), bscApplyInfo.getId(), startParams);
                    BaseLogUtils.info(logger, "modifySplInfoStartFlow", "修改供应商信息,！flowStartedDTO:"+flowStartedDTO== null ? "" :JSON.toJSONString(flowStartedDTO), CurrentThreadContext.getCurrentUserName());
                    if (null != flowStartedDTO && StringUtils.isNotBlank(flowStartedDTO.getMqKey())) {
                        result.setInfo(flowStartedDTO.getMqKey());
                        // 启动流程成功,变更操作
            			try {
            				if (StringUtils.isNotEmpty(reason)) {
								Long add = this.splOpLogRecService.add(id, reason, "apply", "SPL");
                                BaseLogUtils.info(logger, "modifySplInfoStartFlow", "修改供应商信息,！", CurrentThreadContext.getCurrentUserName());
                            }
            			} catch (BaseException e) {
            				BaseLogUtils.info(logger, "updateBlackList", "插入供应商操作记录失败", e);
            			}
                    } else {
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("供应商信息变更流程发起失败！");
                        if(flag){
                            BaseLogUtils.info(logger, "modifySplInfoStartFlow", "修改供应商信息,！", CurrentThreadContext.getCurrentUserName());
                            SysUlFilesRecQueryCondition recQueryCondition = new SysUlFilesRecQueryCondition();
                            recQueryCondition.setPkId(String.valueOf(bscApplyInfo.getId()));
                            recQueryCondition.setIsDel(0);
                            this.sysUlFilesRecService.removeByCondition(recQueryCondition);
                        }
                        BaseLogUtils.info(logger, "modifySplInfoStartFlow", "修改供应商信息,！", CurrentThreadContext.getCurrentUserName());
                    }*/
                }
            } else {
                // 未启动流程,修改操作
                try {
                    if (StringUtils.isNotEmpty(reason)) {
                        Long add = this.splOpLogRecService.add(id, reason, SplRelLogOpTypCdNum.MDF.getOpTypCd(), SplRelLogBizTypCdNum.SPL.getBizTypCd());
                        BaseLogUtils.newWebLogger("插入供应商操作记录结果=>" + add).setLogOperType(LogOperEnum.RESP)
                                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                                .setWarning(false)
                                .info();
                    }
                } catch (BaseException e) {
                    BaseLogUtils.newWebLogger("插入供应商操作记录失败,业务异常").setLogOperType(LogOperEnum.REQ)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                            .setWarning(false)
                            .setThrowable(e)
                            .warn(LogExceptionEnum.COMMON_CODE_0002);
                }
            }
            BaseLogUtils.newWebLogger("修改供应商数据成功.DATA:" + JSONObject.toJSONString(result)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("修改对象失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("修改对象失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return result;
    }


    /**
     * 初始化供应商基本信息
     *
     * @param request
     * @param response
     * @return
     * @throws BaseException
     */
    @RequestMapping(value = "/initSplApplyById.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initSplApplyById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");
        String applyId = request.getParameter("applyId");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(id)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.newWebLogger("获取供应商数据,主键参数为空！").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
            return result;
        }

        try {
            SplInfoVO vo = this.splBscInfoApplyService.selectSplInfoVOById(Long.valueOf(id));

            //供应商类型 jiangzg add 2017-8-8 14:24:02
            Map<String, String> splTypCdMap = new HashMap<>();
            List<SysDictionaryDTO> sysDictionaryDTOList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.SPL_TYP_GRP_CD);
            if (CollectionUtils.isNotEmpty(sysDictionaryDTOList)) {
                for (SysDictionaryDTO sysDictionaryDTO : sysDictionaryDTOList) {
                    splTypCdMap.put(sysDictionaryDTO.getCode(), sysDictionaryDTO.getCodeNm());
                }
            }
            if (null == vo) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
                BaseLogUtils.newWebLogger("获取供应商数据不存在,ID:" + id).setLogOperType(LogOperEnum.RESP)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                        .setWarning(false)
                        .warn(LogExceptionEnum.COMMON_CODE_0002);
            } else {
                //查询变更信息，将变更内容赋值到供应商信息中
                if (StringUtils.isNotBlank(applyId)) {
                    SplBscInfoApplyVO applyVO = this.splBscInfoApplyService.getSplBscInfoApplyById(Long.valueOf(applyId), Long.valueOf(id));
                    if (null != applyVO) {
                        vo.setSplNm(applyVO.getSplNm());
                        vo.setBizLicNo(applyVO.getBizLicNo());
                        vo.setTaxRegNo(applyVO.getTaxRegNo());
                        vo.setOrgCode(applyVO.getOrgCode());
                        vo.setFlowRem(applyVO.getChngFlowRem());
                        vo.setSucc(applyVO.getSucc());
                        vo.setIsRecycleLoa(applyVO.getIsRecycleLoa());
                        vo.setIsUploadLoa(applyVO.getIsUploadLoa());
                        vo.setOwnerCd(applyVO.getOwnerCd());
                        vo.setRgnPrCd(applyVO.getRgnPrCd());
                        vo.setRgnCyCd(applyVO.getRgnCyCd());
                        vo.setPostAddr(applyVO.getPostAddr());
                        //设置新车二手车类型
                        String chkBusTypCdStr = applyVO.getChkBusTypCdStr();
                        List<String> chkBusTypCdList = new ArrayList<>();
                        if (StringUtils.isNotEmpty(chkBusTypCdStr)) {
                            String[] split = chkBusTypCdStr.split(";");
                            for (String s : split) {
                                chkBusTypCdList.add(s);
                            }
                        }
                        StringBuffer newCarCdNms = new StringBuffer();
                        StringBuffer usedCarCdNms = new StringBuffer();
                        //获取经销商类型
                        Map<String, String> kyMap = sysDictionaryApiService.searchGroupToMap(SplSystemConstant.SPL_SYS_CD, WebBaseConstant.SYS_P_ORG_CD, WebBaseConstant.SPL_PROP_CODE_GRP_CD);

                        if(CollectionUtils.isNotEmpty(chkBusTypCdList)){
                            ArrayList<String> newCarList = new ArrayList<>(chkBusTypCdList.size());
                            ArrayList<String> usedCarList = new ArrayList<>(chkBusTypCdList.size());
                            for (String string : chkBusTypCdList) {
                                if(string.contains("2001")){
                                    usedCarList.add(string);
                                    usedCarCdNms.append(kyMap.get(string));
                                    usedCarCdNms.append(",");
                                }else{
                                    newCarList.add(string);
                                    newCarCdNms.append(kyMap.get(string));
                                    newCarCdNms.append(",");
                                }
                            }
                            if(newCarCdNms.length()>1){
                                vo.setNewCarCdNms(newCarCdNms.toString().substring(0,newCarCdNms.length()-1));
                            }else{
                                vo.setNewCarCdNms(null);
                            }
                            if(usedCarCdNms.length()>1){
                                vo.setUsedCarCdNms(usedCarCdNms.toString().substring(0,usedCarCdNms.length()-1));
                            }else{
                                vo.setUsedCarCdNms(null);
                            }
                            if(CollectionUtils.isNotEmpty(newCarList)){
                                String newCarString = this.listTransferToString(newCarList);
                                vo.setNewCarString(newCarString);
                            }else{
                                vo.setNewCarString(null);
                            }
                            if(CollectionUtils.isNotEmpty(usedCarList)){
                                String usedCarString = this.listTransferToString(usedCarList);
                                vo.setUsedCarString(usedCarString);
                            }else{
                                vo.setUsedCarString(null);
                            }
                        }
                    }
                }

                if (CollectionUtils.isMapNotEmpty(splTypCdMap)) {
                    if (splTypCdMap.containsKey(vo.getSplTypCd())) {
                        vo.setSplTypCdNm(splTypCdMap.get(vo.getSplTypCd()));
                    }
                }
            }
            result.setData(vo);
            BaseLogUtils.newWebLogger("获取供应商数据成功,ID:" + id).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("获取供应商数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("获取供应商数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return result;
    }

    /**
     * 初始化主要联系人信息
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initSplRlPsnList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initSplRlPsnList(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        String splId = request.getParameter("splId");
        String applyId = request.getParameter("applyId");
        ListPageVO<SplRlPsnVO> listPage = null;

        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(currentPage)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }
        try {
            SplRlPsnQueryCondition qc = new SplRlPsnQueryCondition();
            qc.setSplId(Long.valueOf(splId));
            page.setCondition(qc);
            page.setEveryPage(Integer.MAX_VALUE);//最大数据量

            Pager pager = this.splBscInfoApplyService.searchSplRlPsnListPage(page);
            List<SplRlPsnVO> list = (List<SplRlPsnVO>) pager.getResultList();
            //将未存在的必输联系人添加
            //list = this.setSplRlPsnList(list);
            list = this.setSplRlPsnList(list, applyId, splId);
            listPage = new ListPageVO<SplRlPsnVO>(list, pager.getTotalCount());
            BaseLogUtils.newWebLogger("初始化供应商联系人列表页面数据.DATA:" + JSONObject.toJSONString(list)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
        } catch (BaseException ex) {
            BaseLogUtils.newWebLogger("初始化主要联系人信息数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            BaseLogUtils.newWebLogger("初始化主要联系人信息数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return listPage;
    }

    /**
     * 初始化变更权限
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/initBizFlowRl.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initBizFlowRl(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String dataId = request.getParameter("dataId");
        String tabNm = request.getParameter("flowTabNm");
        String applyId = request.getParameter("applyId");
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
        if (StringUtils.isEmpty(dataId) || StringUtils.isEmpty(tabNm)) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
            BaseLogUtils.newWebLogger("获取数据,参数不完整.[dataId=" + dataId + ",tabNm=" + tabNm + "]").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
            return result;
        }
        List<SysBizFlowRlVO> list = null;
        //有变更历史记录的，流程权限信息
        Map<String,SysBizFlowRlVO> toAddSysBizFlowRls = null ;
        //SplBiApplyFlowRlVO splBiApplyFlowRlVO = null;
        //流程key-流程权限变更记录
        Map<String,SplBiApplyFlowRlVO> pDefKeyAndApplyFlowRl = null ;
        if (StringUtils.isNotBlank(applyId)) {
            List<SplBiApplyFlowRlVO> applyFlowList = this.splBscInfoApplyService.getSplApplyFlow(Long.valueOf(applyId));
            if (CollectionUtils.isNotEmpty(applyFlowList)) {
                pDefKeyAndApplyFlowRl = new HashMap<>(applyFlowList.size());
                for(SplBiApplyFlowRlVO vo : applyFlowList){
                    pDefKeyAndApplyFlowRl.put(vo.getPDefKey(),vo);
                }
            }
        }
        //流程权限变更配置MAP
        Map<String,String> pDefKeyAndFlowNmMap = this.sysDictionaryApiService.searchGroupToMap(SplSystemConstant.SPL_SYS_CD,SplSystemConstant.DEFAULT_ORG_CD,SplSystemConstant.SPL_FLOW_AUTH_CONFIG_DIC_CD);

        try {
            boolean flag = this.getFlowingState(Long.valueOf(dataId));
            SysBizFlowRlQC sysBizFlowRlQC = new SysBizFlowRlQC();
            sysBizFlowRlQC.setDataId(Long.valueOf(dataId));
            sysBizFlowRlQC.setTabNm(tabNm);
            if (flag) {
                sysBizFlowRlQC.setIsDel(SysBizFlowRlConstant.CODE_FLOW_SAVE_STATUS);
            } else {
                sysBizFlowRlQC.setIsDel(BaseConstant.IS_YESNO_NO);
            }
            list = this.splBscInfoApplyService.searchSysBizFlowRlList(sysBizFlowRlQC);
            if (CollectionUtils.isEmpty(list)) {
                sysBizFlowRlQC.setIsDel(BaseConstant.IS_YESNO_NO);
                list = this.splBscInfoApplyService.searchSysBizFlowRlList(sysBizFlowRlQC);
            }

            //将修改的值覆盖掉现有的值进行显示
            if(CollectionUtils.isNotEmpty(list)){
                Iterator<SysBizFlowRlVO> sysBizFlowRlVOIterator = list.iterator();
                while (sysBizFlowRlVOIterator.hasNext()){
                    SysBizFlowRlVO sysBizFlowRlVO = sysBizFlowRlVOIterator.next();
                    String pDefKey = sysBizFlowRlVO.getPDefKey() ;
                    if(CollectionUtils.isMapNotEmpty(pDefKeyAndFlowNmMap) && pDefKeyAndFlowNmMap.containsKey(pDefKey)
                            && CollectionUtils.isMapNotEmpty(pDefKeyAndApplyFlowRl) && pDefKeyAndApplyFlowRl.containsKey(pDefKey)){
                        if(CollectionUtils.isMapEmpty(toAddSysBizFlowRls)){
                            toAddSysBizFlowRls = new HashMap<>(4);
                        }
                        toAddSysBizFlowRls.put(sysBizFlowRlVO.getPDefKey(),sysBizFlowRlVO);
                        sysBizFlowRlVOIterator.remove();
                    }
                }
                if(CollectionUtils.isMapNotEmpty(pDefKeyAndApplyFlowRl)){
                    if(CollectionUtils.isMapNotEmpty(toAddSysBizFlowRls)){
                        for(Map.Entry<String,SplBiApplyFlowRlVO> entry : pDefKeyAndApplyFlowRl.entrySet()){
                            SplBiApplyFlowRlVO splBiApplyFlowRlVO = entry.getValue() ;
                            SysBizFlowRlVO vo = null ;
                            if(toAddSysBizFlowRls.containsKey(entry.getKey())){
                                vo = toAddSysBizFlowRls.get(entry.getKey());
                            }else{
                                vo = new SysBizFlowRlVO();
                                vo.setTabNm(splBiApplyFlowRlVO.getTabNm());
                            }
                            vo.setIsDel(splBiApplyFlowRlVO.getIsDel());
                            vo.setFlowNum(splBiApplyFlowRlVO.getFlowNum());
                            vo.setDataId(splBiApplyFlowRlVO.getDataId());
                            vo.setpDefKey(splBiApplyFlowRlVO.getPDefKey());
                            list.add(vo);
                        }
                    }else{
                        for(Map.Entry<String,SplBiApplyFlowRlVO> entry : pDefKeyAndApplyFlowRl.entrySet()){
                            SplBiApplyFlowRlVO splBiApplyFlowRlVO = entry.getValue() ;
                            SysBizFlowRlVO vo = new SysBizFlowRlVO();
                            vo.setTabNm(splBiApplyFlowRlVO.getTabNm());
                            vo.setIsDel(splBiApplyFlowRlVO.getIsDel());
                            vo.setFlowNum(splBiApplyFlowRlVO.getFlowNum());
                            vo.setDataId(splBiApplyFlowRlVO.getDataId());
                            vo.setpDefKey(splBiApplyFlowRlVO.getPDefKey());
                            list.add(vo);
                        }
                    }
                }
            }
            result.setData(list);
            BaseLogUtils.newWebLogger("获取数据.[dataId=" + dataId + ",tabNm=" + tabNm + "]").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("初始化变更权限失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.newWebLogger("初始化变更权限失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }

        return result;
    }


    @ResponseBody
    @RequestMapping(value = "/toSplInfoApplyListPage.do", method = {RequestMethod.GET})
    public ModelAndView toSplInfoApplyListPage(HttpServletRequest request, HttpServletResponse response) {
        String splId = request.getParameter("splId");
        ModelAndView view = new ModelAndView("product/splInfoApply/splInfoApplyList");
        view.addObject("splId", splId);
        return view;
    }

    @ResponseBody
    @RequestMapping(value = "/initSplInfoApplyList.do", method = {RequestMethod.GET})
    public Object initSplInfoApplyList(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        String splId = request.getParameter("splId");
        ListPageVO<SplBscInfoApplyVO> listPage = null;
        try {
            Pager page = new Pager();
            if (StringUtils.isNotEmpty(currentPage)) {
                page.setCurrentPage(Integer.parseInt(currentPage));
            }

            if (StringUtils.isNotEmpty(currentPage)) {
                page.setEveryPage(Integer.parseInt(pageSize));
            }

            SplBscInfoApplyQC qc = new SplBscInfoApplyQC();
            if (StringUtils.isNotBlank(splId)) {
                qc.setSplId(Long.valueOf(splId));
            }
            page.setCondition(qc);
            BaseLogUtils.newWebLogger("初始化供应商变更列表页面数据.DATA:" + JSONObject.toJSONString(page)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            Pager pager = this.splBscInfoApplyService.searchSplApplyListPage(page);
            List<SplBscInfoApplyVO> splBscInfoApplyVOList = (List<SplBscInfoApplyVO>) pager.getResultList();
            listPage = new ListPageVO<>(splBscInfoApplyVOList, pager.getTotalCount());
        } catch (BaseException ex) {
            BaseLogUtils.newWebLogger("初始化供应商变更列表失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            BaseLogUtils.newWebLogger("初始化供应商变更列表失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return listPage;
    }

    /**
     * 发起变更流程
     */
    @RequestMapping(value = "/addSplChangeFlowStart.do", method = {RequestMethod.POST})
    @ResponseBody
    public Object addSplChangeFlowStart(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO resultVO = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
        String id = request.getParameter("id");
        try {
            if (StringUtils.isBlank(id)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "变更ID不能为空");
            }
            Long splId = null;//用不上
            //获取供应商基本信息
            SplBscInfoApplyVO splBscInfoApplyVO = this.splBscInfoApplyService.getSplBscInfoApplyById(Long.valueOf(id), splId);
            if (null != splBscInfoApplyVO) {
                if (StringUtils.isNotEmpty(splBscInfoApplyVO.getSplId())) {
                    String message = this.splBscInfoApplyService.getFlowMessage(splBscInfoApplyVO.getSplId());
                    if (StringUtils.isNotBlank(message)) {
                        throw new BaseException(BaseExceptionConstant.COMMON_0001, "该供应商在" + message + "等事业部存在审核中流程，暂不能发起变更流程.");
                    }
                }
                //启动流程审核
                if (BaseConstant.IS_YESNO_YES == splBscInfoApplyVO.getIsChngBaseData() || BaseConstant.IS_YESNO_YES == splBscInfoApplyVO.getIsChngLoanFlow()) {
                    Map<String, Object> startParams = new HashMap<String, Object>();
                    startParams.put("isChngBaseData", splBscInfoApplyVO.getIsChngBaseData());
                    startParams.put("isChngLoanFlow", splBscInfoApplyVO.getIsChngLoanFlow());
//                    startParams.put("isFlowNumCount", this.splBscInfoApplyService.getFlowNumcount(Long.valueOf(Long.valueOf(id))));
                    this.addFlowStart(request, splId, splBscInfoApplyVO.getId(), startParams);
                    /*FlowStartedDTO flowStartedDTO = this.addFlowStart(request, splId, splBscInfoApplyVO.getId(), startParams);
                    if (StringUtils.isNotBlank(flowStartedDTO.getMqKey())) {
                        resultVO.setInfo(flowStartedDTO.getMqKey());
                    } else {
                        resultVO.setInfo("供应商信息变更流程发起成功");
                    }*/
                }
            }
            BaseLogUtils.newWebLogger("发起供应商变更流程成功," + ".DATA:" + JSONObject.toJSONString(id)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
        } catch (BaseException ex) {
            resultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            resultVO.setInfo(ex.getMessage());
            BaseLogUtils.newWebLogger("发起供应商变更流程失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            resultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            resultVO.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.newWebLogger("发起供应商变更流程失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return resultVO;
    }

    @ResponseBody
    @RequestMapping(value = "/toSplInfoApplyChangeDetail.do", method = {RequestMethod.GET})
    public ModelAndView toSplInfoApplyChangeDetail(HttpServletRequest request, HttpServletResponse response) {
        String id = request.getParameter("id");
        ModelAndView view = new ModelAndView("product/splInfoApply/changeDetail");

        SplBscInfoApplyVO splBscInfoApplyVO = this.splBscInfoApplyService.getSplBscInfoApplyById(Long.valueOf(id), null);

        List<SplBiApplyFlowRlVO> splBiApplyFlowRlVOList = this.splBscInfoApplyService.getSplApplyFlow(Long.valueOf(id));

        //重卡放款流程
        List<KeyValueVO> kvList = this.splBscInfoApplyService.getKvList();

        if (CollectionUtils.isNotEmpty(splBiApplyFlowRlVOList)) {
            for (SplBiApplyFlowRlVO splBiApplyFlowRlVO : splBiApplyFlowRlVOList) {
                String pdefKey = splBiApplyFlowRlVO.getPDefKey();//变更后
                String pdefKeyB = splBiApplyFlowRlVO.getPDefKeyB();//变更前
                if (StringUtils.isNotBlank(pdefKey)) {
                    for (KeyValueVO KeyValueVO : kvList) {
                        if (KeyValueVO.getKey().equals(pdefKey)) {
                            splBiApplyFlowRlVO.setPDefKeynm(KeyValueVO.getValue());
                        }
                    }
                }
                if (StringUtils.isNotBlank(pdefKeyB)) {
                    for (KeyValueVO KeyValueVO : kvList) {
                        if (KeyValueVO.getKey().equals(pdefKeyB)) {
                            splBiApplyFlowRlVO.setPDefKeyBnm(KeyValueVO.getValue());
                        }
                    }
                }
            }
        }
        view.addObject("kvList", kvList);
        view.addObject("splBscInfoApplyVO", splBscInfoApplyVO);
        view.addObject("splBiApplyFlowRlVOList", JSONArray.fromObject(splBiApplyFlowRlVOList));
        view.addObject("id", id);
        BaseLogUtils.newWebLogger("跳转到供应商变更详情id:" + id).setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
        return view;
    }

    @ResponseBody
    @RequestMapping(value = "/initSplInfoApplyRlPsnList.do", method = {RequestMethod.GET})
    public Object initSplInfoApplyRlPsnList(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        String id = request.getParameter("id");//供应商变更ID
        List<SplBiApplyRlPsnVO> splBiApplyRlPsnVOList = this.splBscInfoApplyService.getSplRlPsnApplyById(null, Long.valueOf(id));
        int total = 0;
        if (CollectionUtils.isNotEmpty(splBiApplyRlPsnVOList)) {
            total = splBiApplyRlPsnVOList.size();
        }
        ListPageVO<SplBiApplyRlPsnVO> listPage = new ListPageVO<>(splBiApplyRlPsnVOList, total);
        return listPage;
    }
    //********************私有方法********************//


    /**
     * 通过姓名身份证号码验证信息是否正确
     *
     * @param cstNm
     * @param certNo
     * @return
     * @throws BaseException
     */
    private void validateIdCard(String typeNm, String cstNm, String certNo) throws BaseException {
        //验证身份证号格式
        this.checkVIDInfoItem(typeNm, cstNm, certNo);
        //调用第三方接口验证证件信息
        this.validCert(typeNm, cstNm, certNo, "身份证信息验证未通过!", "validateIdCard");
    }

    /**
     * 检查主要人员重要信息项
     *
     * @param cstNm  姓名
     * @param certNo 证件号码
     */
    private void checkVIDInfoItem(String typeNm, String cstNm, String certNo) throws BaseException {
        String certTypCd = DictionaryConstant.CODE_CERT_TYP_CD_0;

        // 验证必填项及长度
        if (StringUtils.isBlank(cstNm) || cstNm.length() > 20 || !StringUtils.isCustomerName(cstNm)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, typeNm + "【" + certNo + "】" + PrjLnkCompRelInfoConstant.LOG_VALID_NM);
        }

        if (StringUtils.isBlank(certNo)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, typeNm + "【" + cstNm + "】" + PrjLnkCompRelInfoConstant.LOG_VALID_CERT_NO_EMPTY);
        }

        if (certTypCd.equals(DictionaryConstant.CODE_CERT_TYP_CD_0) && !StringUtils.isIdCardNumber(certNo)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, typeNm + "【" + cstNm + "】" + PrjLnkCompRelInfoConstant.LOG_VALID_CERT_NO_ERROR);
        }
    }

    /**
     * 证件验证
     *
     * @param certNm 证件名称
     * @param certNo 证件号码
     */
    private void validCert(String typeNm, String certNm, String certNo, String errorDesc, String funName) throws BaseException {
        CstValidCardInfoVO cstValidCardInfoVO = this.splBscInfoApplyService.validateCstCert(certNm, certNo);
        if (!cstValidCardInfoVO.getSuccess()) {
            //第三方验证未通过
            String info = errorDesc + " certNm:" + certNm + " - certNo:" + certNo;
            BaseLogUtils.newWebLogger(funName + info).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            throw new BaseException(BaseExceptionConstant.COMMON_0001, typeNm + "【" + certNm + "】" + errorDesc);
        }
    }


    //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
    /**
     * 变更页面加载流程权限信息
     *
     * @param view
     * @param request
     *//*
    private void setBizFlowValue(ModelAndView view, HttpServletRequest request, String dataId) {
        String codeGrpCd = "FLW0001";//数据字典组
        List<KeyValueVO> kvList = this.getKvList(codeGrpCd);
        view.addObject("kvList", kvList);
        view.addObject("kvListJSON", JSONArray.fromObject(kvList));
    }*/

    /**
     * 根据字典中代码组值获取组员集合
     *
     * @param grpCd 代码组值
     * @return 集合
     */
    private List<KeyValueVO> getKvList(String grpCd) {
        List<KeyValueVO> kvList = new ArrayList<>();
        try {
            List<SysDictionaryDTO> sysDictionaryDTOList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), grpCd);
            if (CollectionUtils.isNotEmpty(sysDictionaryDTOList)) {
                for (SysDictionaryDTO sysDictionaryDTO : sysDictionaryDTOList) {
                    KeyValueVO keyValueVO = new KeyValueVO();
                    keyValueVO.setKey(sysDictionaryDTO.getCode());
                    keyValueVO.setValue(sysDictionaryDTO.getCodeNm());
                    kvList.add(keyValueVO);
                }
            }
        } catch (BaseException ex) {
            BaseLogUtils.newWebLogger("获取字典项组" + grpCd + "失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            BaseLogUtils.newWebLogger("获取字典项组" + grpCd + "失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        return kvList;
    }

    /**
     * 封装必输联系人信息
     *
     * @param voList
     */
    private List<SplRlPsnVO> setSplRlPsnList(List<SplRlPsnVO> voList, String applyId, String splId) {
        //证件类型
        List<KeyValueVO> certTypCdList = this.splBscInfoApplyService.searchCertTypCdList();
        //获取默认证件类型名称
        String defCodNm = "";
        
        List<Long> removeIds = new ArrayList<>();
        for (KeyValueVO keyValueVO : certTypCdList) {
            if (keyValueVO.getKey().equals(SplInfoConstant.CODE_CERT_TYP_DEF_CD)) {
                defCodNm = keyValueVO.getValue();
                break;
            }
        }
        //必填联系人类型
        List<SysDictionaryDTO> mustAddRlPsnTypCds = this.sysDictionaryApiService.searchGroupAll(CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(),DictionaryConstant.CODE_RL_TYP_CD);
        List<String> mustAddRlPsns = null ;
        if(CollectionUtils.isNotEmpty(mustAddRlPsnTypCds)){
            mustAddRlPsns = new ArrayList<>(mustAddRlPsnTypCds.size());
            for(SysDictionaryDTO dto : mustAddRlPsnTypCds){
                if(BaseConstant.IS_YESNO_YES == dto.getIsSysDef()){
                    mustAddRlPsns.add(dto.getCode());
                }
            }
        }
        List<KeyValueVO> rlTypCDList = this.splBscInfoApplyService.searchRlTypCdList();
        Map<String, SplRlPsnVO> map = new HashMap<String, SplRlPsnVO>();
        //查询出所有必输联系人信息
        if (null != rlTypCDList && rlTypCDList.size() > 0) {
            for (KeyValueVO keyValueVO : rlTypCDList) {
                if (!keyValueVO.getKey().equals(SplInfoConstant.SPL_RL_TYP_CD_ACTUAL_2)
                        && (CollectionUtils.isNotEmpty(mustAddRlPsns) && mustAddRlPsns.contains(keyValueVO.getKey()) || CollectionUtils.isEmpty(mustAddRlPsns))) {
                    SplRlPsnVO vo = new SplRlPsnVO();
                    vo.setRlTypCd(keyValueVO.getKey());
                    vo.setRlTypCdNm(keyValueVO.getValue());
                    vo.setCertTypCd(SplInfoConstant.CODE_CERT_TYP_DEF_CD);
                    vo.setCertTypCdNm(defCodNm);
                    vo.setIsDel(BaseConstant.IS_YESNO_NO);
                    vo.setIsDefault(BaseConstant.IS_YESNO_YES);
                    map.put(keyValueVO.getKey(), vo);
                }
            }
        }
        //判断修改的联系人信息中是否存在必输的联系人
        if (null == voList || voList.size() <= 0) {
            voList = new ArrayList<SplRlPsnVO>();
        }
        Map<Long, SplBiApplyRlPsnVO> applyMap = null;
        //变更主表ID不为空，查询出该主要联系人所有信息
        if (StringUtils.isNotBlank(applyId)) {
            applyMap = new HashMap<Long, SplBiApplyRlPsnVO>();
            List<SplBiApplyRlPsnVO> applyRlPsnVOs = this.splBscInfoApplyService.getSplRlPsnApplyById(null, Long.valueOf(applyId));
            BaseLogUtils.newWebLogger("查询供应商变更联系人信息："+JSON.toJSONString(applyRlPsnVOs)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            if (null != applyRlPsnVOs) {
                for (SplBiApplyRlPsnVO rlPsnVo : applyRlPsnVOs) {
                	if(BaseConstant.IS_YESNO_YES == rlPsnVo.getIsDel()){
                		removeIds.add(rlPsnVo.getSplRlPsnId());
                	}
                	if (StringUtils.isNotEmpty(rlPsnVo.getSplRlPsnId())) {
                		applyMap.put(rlPsnVo.getSplRlPsnId(), rlPsnVo);
                	} else {
                		applyMap.put(rlPsnVo.getId(), rlPsnVo);
                	}
                }
            }
        }
        BaseLogUtils.newWebLogger("删除的联系人ID集合："+JSON.toJSONString(removeIds)).setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
        //循环将已经存在的vo信息
        for (SplRlPsnVO splRlPsnVO : voList) {
            if (StringUtils.isNotBlank(applyId)) {
                //去除未变更的默认主要联系人信息
                //if (null != splRlPsnVO.getIsDefault() && BaseConstant.IS_YESNO_YES == splRlPsnVO.getIsDefault()) {
                if (StringUtils.isNotEmpty(splRlPsnVO.getRlTypCd()) && BaseConstant.IS_YESNO_YES_STR.equals(splRlPsnVO.getRlTypCd())) {
                    //查询修改记录
                    Long splRlId = splRlPsnVO.getId();
                    SplBiApplyRlPsnVO rlPsnVo = applyMap.get(splRlId);
                    if (null != rlPsnVo) {
                        splRlPsnVO.setRlNm(rlPsnVo.getRlNm());
                        splRlPsnVO.setCertTypCd(rlPsnVo.getCertTypCd());
                        splRlPsnVO.setCertNo(rlPsnVo.getCertNo());
                        splRlPsnVO.setRlTypCd(rlPsnVo.getRlTypCd());
                        splRlPsnVO.setTel(rlPsnVo.getTel());
                        splRlPsnVO.setApplyPsnId(rlPsnVo.getId());
                        splRlPsnVO.setBrPerVerify(rlPsnVo.getBrPerVerify());
                        splRlPsnVO.setBusInfoVerify(rlPsnVo.getBusInfoVerify());
                        splRlPsnVO.setTdPerVerify(rlPsnVo.getTdPerVerify());
                        splRlPsnVO.setPyPerVerify(rlPsnVo.getPyPerVerify());
                        applyMap.remove(splRlId);
                    }
                }
            }
            //如果存在必输联系人，将必输Map中联系人去除
            if (map.containsKey(splRlPsnVO.getRlTypCd())) {
                map.remove(splRlPsnVO.getRlTypCd());
            }
        }
        if (null != applyMap && applyMap.size() > 0) {
            for (SplBiApplyRlPsnVO rlPsnVo : applyMap.values()) {
                SplRlPsnVO vo = new SplRlPsnVO();
                vo.setId(rlPsnVo.getSplRlPsnId());
                vo.setIsDefault(rlPsnVo.getIsDefault());
                if (StringUtils.isNotEmpty(splId)) {
                    vo.setSplId(Long.valueOf(splId));
                }
                vo.setRlNm(rlPsnVo.getRlNm());
                vo.setCertTypCd(rlPsnVo.getCertTypCd());
                vo.setCertNo(rlPsnVo.getCertNo());
                vo.setRlTypCd(rlPsnVo.getRlTypCd());
                vo.setTel(rlPsnVo.getTel());
                vo.setRlRem(rlPsnVo.getRlRem());
                vo.setApplyPsnId(rlPsnVo.getId());

                vo.setBrPerVerify(rlPsnVo.getBrPerVerify());
                vo.setBusInfoVerify(rlPsnVo.getBusInfoVerify());
                vo.setTdPerVerify(rlPsnVo.getTdPerVerify());
                vo.setPyPerVerify(rlPsnVo.getPyPerVerify());
                voList.add(vo);

                //如果存在必输联系人，将必输Map中联系人去除
                if (map.containsKey(vo.getRlTypCd())) {
                    map.remove(vo.getRlTypCd());
                }
            }
        }

        //将去除重复后的必输联系人添加到联系人列表中
        if (null != map && map.size() > 0) {
            for (Map.Entry<String, SplRlPsnVO> entry : map.entrySet()) {
                voList.add(entry.getValue());
            }
        }
        List<SplRlPsnVO> returnList = new ArrayList<>();
        for(int i = 0; i<voList.size() ; i++){
        	if(!removeIds.contains(voList.get(i).getId())){
        		returnList.add(voList.get(i));
        	}
        }
        this.setPrdSplRlPsnDTOWithDicInfo(returnList, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
        return returnList;
    }

    /**
     * 保存供应商基本信息
     *
     * @param request
     * @param oldSplInfoVO
     * @param flag 是否变更
     * @return
     */
    private boolean toSaveBscApplyInfoVo(HttpServletRequest request, SplInfoVO oldSplInfoVO , boolean flag) throws BaseException {
        SplInfoVO prdSplInfoVO = this.getRequestParamForPrdSpl(request, oldSplInfoVO.getId(),oldSplInfoVO,flag);
        prdSplInfoVO.setSplNm(oldSplInfoVO.getSplNm());
        prdSplInfoVO.setTaxRegNo(oldSplInfoVO.getTaxRegNo());
        prdSplInfoVO.setBizLicNo(oldSplInfoVO.getBizLicNo());
        prdSplInfoVO.setOrgCode(oldSplInfoVO.getOrgCode());
        prdSplInfoVO.setId(oldSplInfoVO.getId());
        prdSplInfoVO.setRlPsnList(null);
        prdSplInfoVO.setOwnerCd(oldSplInfoVO.getOwnerCd());
        prdSplInfoVO.setRgnPrCd(oldSplInfoVO.getRgnPrCd());
        prdSplInfoVO.setRgnCyCd(oldSplInfoVO.getRgnCyCd());
        prdSplInfoVO.setPostAddr(oldSplInfoVO.getPostAddr());
        prdSplInfoVO.setChkBusTypCdList(oldSplInfoVO.getChkBusTypCdList());

        return this.splBscInfoApplyService.modifySplInfoVO(prdSplInfoVO);
    }


    /**
     * 修改挂靠公司基础数据修改
     *
     * @param request
     * @param splRlPsnVOs
     * @param splId
     */
    private void saveBiApplyPsn(HttpServletRequest request, List<SplRlPsnVO> splRlPsnVOs, Long splId) {
        String npSocialRlGridJSON = request.getParameter("npSocialRlGridJSON");
        //页面中主要联系人信息
        List<SplRlPsnVO> rlPsnList = new ArrayList<SplRlPsnVO>();
        if (null != npSocialRlGridJSON) {
            rlPsnList = JSON.parseArray(npSocialRlGridJSON, SplRlPsnVO.class);
        }
        Map<Long, SplRlPsnVO> maps = new HashMap<Long, SplRlPsnVO>();
        //将页面中的默认主要联系人信息变更为原有信息（备注不变）
        if (null != splRlPsnVOs && splRlPsnVOs.size() > 0) {
            for (SplRlPsnVO splRlPsnVO : splRlPsnVOs) {
                //if (StringUtils.isNotEmpty(splRlPsnVO.getIsDefault()) && BaseConstant.IS_YESNO_YES == splRlPsnVO.getIsDefault()) {
                if (StringUtils.isNotEmpty(splRlPsnVO.getRlTypCd()) && BaseConstant.IS_YESNO_YES_STR.equals(splRlPsnVO.getRlTypCd())) {
                    maps.put(splRlPsnVO.getId(), splRlPsnVO);
                }
            }
        }
        if (null != rlPsnList && rlPsnList.size() > 0) {
            for (SplRlPsnVO splRlPsnVO : rlPsnList) {
                //if (StringUtils.isNotEmpty(splRlPsnVO.getIsDefault()) && BaseConstant.IS_YESNO_YES == splRlPsnVO.getIsDefault()) {
                if (StringUtils.isNotEmpty(splRlPsnVO.getRlTypCd()) && BaseConstant.IS_YESNO_YES_STR.equals(splRlPsnVO.getRlTypCd())) {
                    if (StringUtils.isNotEmpty(splRlPsnVO.getId())) {
                        SplRlPsnVO oldVo = maps.get(splRlPsnVO.getId());
                        if (null != oldVo) {
                            splRlPsnVO.setRlNm(oldVo.getRlNm());
                            splRlPsnVO.setCertTypCd(oldVo.getCertTypCd());
                            splRlPsnVO.setCertNo(oldVo.getCertNo());
                            splRlPsnVO.setRlTypCd(oldVo.getRlTypCd());
                            splRlPsnVO.setTel(oldVo.getTel());
                            splRlPsnVO.setIsDel(oldVo.getIsDel());
                            splRlPsnVO.setMdfTm(new Date());
                            splRlPsnVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                        }
                    } else {
                        splRlPsnVO.setCrtTm(new Date());
                        splRlPsnVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    }
                }
                if (StringUtils.isEmpty(splRlPsnVO.getSplId())) {
                    splRlPsnVO.setSplId(splId);
                }
            }
        }
        //保存重要联系人信息
        for (SplRlPsnVO splRlPsnVO : rlPsnList) {
            splRlPsnVO.setBrPerVerify("2");
            splRlPsnVO.setTdPerVerify("2");
            splRlPsnVO.setPyPerVerify("2");
            splRlPsnVO.setBusInfoVerify("2");
        }
        this.splBscInfoApplyService.modifySplBiPsn(rlPsnList);
    }

    /**
     * 检查供应商信息是否发生变化
     * @param request  请求信息
     * @param applyId  申请变更ID
     * @param oldSplInfoVO 旧经销商信息
     * @return
     */
    private SplBscInfoApplyVO checkBscApplyInfo(HttpServletRequest request, SplInfoVO oldSplInfoVO, Long applyId) {
        //经销商基础信息变更信息
        SplBscInfoApplyVO bscInfoApplyVO = null;
        //获取页面中供应商名称，税务登记号，营业执照，组织机构代码
        String splNm = request.getParameter("splNm");//供应商名称
        String taxRegNo = request.getParameter("taxRegNo");//税务登记号
        String bizLicNo = request.getParameter("bizLicNo");//营业执照注册号
        String orgCode = request.getParameter("orgCode");//组织机构代码号
        String flowRem = request.getParameter("flowRem");//备注说明
        String succ = request.getParameter("succ"); //统一社会信用代码
        String isUploadLoa = request.getParameter("isUploadLoa");
        String isRecycleLoa = request.getParameter("isRecycleLoa");
        String ownerCd = request.getParameter("ownerCd");//公司归属
        String rgnPrCd = request.getParameter("rgnPrCd");//区域 省CD
        String rgnCyCd = request.getParameter("rgnCyCd");//区域 市CD
        String postAddr = request.getParameter("postAddr");//办公地址
        String newCarTyp = request.getParameter("newCarTyp");//经营类型(新车)
        String usedCarTyp = request.getParameter("usedCarTyp");// 经营类型(二手车)

        //商家APP 增加字段   by ZHAOYONG end 20170829
        splNm = org.springframework.util.StringUtils.replace(splNm, "（", "(");
        splNm = org.springframework.util.StringUtils.replace(splNm, "）", ")");

        //变更id不存在获取主表信息
        if (StringUtils.isNotEmpty(applyId)) {
            bscInfoApplyVO = this.splBscInfoApplyService.getSplBscInfoApplyById(applyId, null);
        } else {
            bscInfoApplyVO = new SplBscInfoApplyVO();
            bscInfoApplyVO.setSplId(oldSplInfoVO.getId());
            bscInfoApplyVO.setSplNmB(oldSplInfoVO.getSplNm());
            bscInfoApplyVO.setSplNm(oldSplInfoVO.getSplNm());
            bscInfoApplyVO.setSuccB(oldSplInfoVO.getSucc());
            bscInfoApplyVO.setSucc(oldSplInfoVO.getSucc());
            bscInfoApplyVO.setBizLicNoB(oldSplInfoVO.getBizLicNo());
            bscInfoApplyVO.setBizLicNo(oldSplInfoVO.getBizLicNo());
            bscInfoApplyVO.setTaxRegNoB(oldSplInfoVO.getTaxRegNo());
            bscInfoApplyVO.setTaxRegNo(oldSplInfoVO.getTaxRegNo());
            bscInfoApplyVO.setOrgCodeB(oldSplInfoVO.getOrgCode());
            bscInfoApplyVO.setOrgCode(oldSplInfoVO.getOrgCode());
            bscInfoApplyVO.setIsMerge(BaseConstant.IS_YESNO_NO);
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_NO);
            bscInfoApplyVO.setIsChngLoanFlow(BaseConstant.IS_YESNO_NO);
            bscInfoApplyVO.setStatus(BaseConstant.IS_YESNO_YES);
            bscInfoApplyVO.setCrtTmB(oldSplInfoVO.getCrtTm());
            bscInfoApplyVO.setCrtUsrIdB(oldSplInfoVO.getCrtUsrId());
            bscInfoApplyVO.setCrtUsrId(oldSplInfoVO.getCrtUsrId());
            bscInfoApplyVO.setMdfTmB(oldSplInfoVO.getMdfTm());
            bscInfoApplyVO.setMdfUsrIdB(oldSplInfoVO.getMdfUsrId());
            bscInfoApplyVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
            bscInfoApplyVO.setCstMgrId(CurrentThreadContext.getCurrentUserId());
            bscInfoApplyVO.setCstMgrNm(CurrentThreadContext.getCurrentUserName());
            bscInfoApplyVO.setCstMgrOrgCd(CurrentThreadContext.getCurrentOrgCd());
            bscInfoApplyVO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
            
            bscInfoApplyVO.setIsRecycleLoa(oldSplInfoVO.getIsRecycleLoa());
            bscInfoApplyVO.setIsRecycleLoaB(oldSplInfoVO.getIsRecycleLoa());
            bscInfoApplyVO.setIsUploadLoa(oldSplInfoVO.getIsUploadLoa());
            bscInfoApplyVO.setIsUploadLoaB(oldSplInfoVO.getIsUploadLoa());
            //bscInfoApplyVO.setIsValid(BaseConstant.IS_YESNO_YES);
            bscInfoApplyVO.setOwnerCdB(oldSplInfoVO.getOwnerCd());
            bscInfoApplyVO.setOwnerCd(oldSplInfoVO.getOwnerCd());
            bscInfoApplyVO.setRgnPrCdB(oldSplInfoVO.getRgnPrCd());
            bscInfoApplyVO.setRgnPrCd(oldSplInfoVO.getRgnPrCd());
            bscInfoApplyVO.setRgnCyCdB(oldSplInfoVO.getRgnCyCd());
            bscInfoApplyVO.setRgnCyCd(oldSplInfoVO.getRgnCyCd());
            bscInfoApplyVO.setPostAddrB(oldSplInfoVO.getPostAddr());
            bscInfoApplyVO.setPostAddr(oldSplInfoVO.getPostAddr());
            List<String> chkBusTypCdList = oldSplInfoVO.getChkBusTypCdList();
            StringBuffer chkBusTypCdListStr = null;
            if (CollectionUtils.isNotEmpty(chkBusTypCdList)) {
                for (String s : chkBusTypCdList) {
                    if (null == chkBusTypCdListStr) {
                        chkBusTypCdListStr = new StringBuffer(s);
                    } else {
                        chkBusTypCdListStr.append(";").append(s);
                    }
                }
            }
            if (null != chkBusTypCdListStr) {
                bscInfoApplyVO.setChkBusTypCdStrB(chkBusTypCdListStr.toString());
                bscInfoApplyVO.setChkBusTypCdStr(chkBusTypCdListStr.toString());
            }
        }
        bscInfoApplyVO.setChngFlowRem(flowRem);
        //判断主表信息是否为空，有变更时将基本数据信息变更状态为1
        if (StringUtils.isNotEmpty(splNm.trim()) && !splNm.trim().equals(bscInfoApplyVO.getSplNm())) {
            bscInfoApplyVO.setSplNm(splNm.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        if (StringUtils.isNotEmpty(isUploadLoa) && !isUploadLoa.trim().equals(bscInfoApplyVO.getIsUploadLoa())) {
        	bscInfoApplyVO.setIsUploadLoa(Integer.valueOf(isUploadLoa));
        	bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        if (StringUtils.isNotEmpty(isRecycleLoa) && !isRecycleLoa.trim().equals(bscInfoApplyVO.getIsRecycleLoa())) {
        	bscInfoApplyVO.setIsRecycleLoa(Integer.valueOf(isRecycleLoa));
        	bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        
        /*if (StringUtils.isNotEmpty(taxRegNo) && !taxRegNo.trim().equals(bscInfoApplyVO.getTaxRegNo())) {
            bscInfoApplyVO.setTaxRegNo(taxRegNo.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }

        if (StringUtils.isNotEmpty(bizLicNo) && !bizLicNo.trim().equals(bscInfoApplyVO.getBizLicNo())) {
            bscInfoApplyVO.setBizLicNo(bizLicNo.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        if (StringUtils.isNotEmpty(orgCode) && !orgCode.trim().equals(bscInfoApplyVO.getOrgCode())) {
            bscInfoApplyVO.setOrgCode(orgCode.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }*/
        if (StringUtils.isNotEmpty(succ) && !succ.trim().equals(bscInfoApplyVO.getSucc())) {
            bscInfoApplyVO.setSucc(succ.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        if (StringUtils.isNotEmpty(ownerCd) && !ownerCd.trim().equals(bscInfoApplyVO.getOwnerCd())) {
            bscInfoApplyVO.setOwnerCd(ownerCd.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        if (StringUtils.isNotEmpty(rgnPrCd) && !rgnPrCd.trim().equals(bscInfoApplyVO.getRgnPrCd())) {
            bscInfoApplyVO.setRgnPrCd(rgnPrCd.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        if (StringUtils.isNotEmpty(rgnCyCd) && !rgnCyCd.trim().equals(bscInfoApplyVO.getRgnCyCd())) {
            bscInfoApplyVO.setRgnCyCd(rgnCyCd.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        if (StringUtils.isNotEmpty(postAddr) && !postAddr.trim().equals(bscInfoApplyVO.getPostAddr())) {
            bscInfoApplyVO.setPostAddr(postAddr.trim());
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        StringBuffer chkBusTypCdStrBuffer = null;
        List<String> propTypCdList = new ArrayList<String>();
        if(StringUtils.isNotEmpty(newCarTyp)){
            String[] newCarTypCdStr = newCarTyp.split(";");
            if(newCarTypCdStr.length > 0){
                for (String newCar : newCarTypCdStr) {
                    propTypCdList.add(newCar);
                }
            }
            chkBusTypCdStrBuffer = new StringBuffer(newCarTyp);
        }
        if(StringUtils.isNotEmpty(usedCarTyp)){
            String[] usedCarTypCdStr = usedCarTyp.split(";");
            if(usedCarTypCdStr.length > 0){
                for (String usedCar : usedCarTypCdStr) {
                    propTypCdList.add(usedCar);
                }
            }
            if (null == chkBusTypCdStrBuffer) {
                chkBusTypCdStrBuffer = new StringBuffer(usedCarTyp);
            } else {
                chkBusTypCdStrBuffer.append(";").append(usedCarTyp);
            }
        }
        if(CollectionUtils.isNotEmpty(propTypCdList) && null != chkBusTypCdStrBuffer){
            List<String> chkBusTypCdList = oldSplInfoVO.getChkBusTypCdList();
            if (CollectionUtils.isEmpty(chkBusTypCdList)) {
                bscInfoApplyVO.setChkBusTypCdStr(chkBusTypCdStrBuffer.toString());
                bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
            } else {
                if (chkBusTypCdList.size() == propTypCdList.size()) {
                    for (String s : chkBusTypCdList) {
                        if (!propTypCdList.contains(s)) {
                            bscInfoApplyVO.setChkBusTypCdStr(chkBusTypCdStrBuffer.toString());
                            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
                        }
                    }
                } else {
                    bscInfoApplyVO.setChkBusTypCdStr(chkBusTypCdStrBuffer.toString());
                    bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
                }
            }
        } else if (CollectionUtils.isNotEmpty(oldSplInfoVO.getChkBusTypCdList())) {
            bscInfoApplyVO.setChkBusTypCdStr(null);
            bscInfoApplyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
        }
        return bscInfoApplyVO;
    }


    /**
     * 检查重要联系人是否发生变化
     *
     * @param request
     * @param oldSplRlPsnVOList
     * @param applyId
     * @return
     */
    private Map checkBiApplyRlPsn(HttpServletRequest request, List<SplRlPsnVO> oldSplRlPsnVOList, Long applyId) {
        Map<String, Object> map = new HashMap();
        int modifyState = BaseConstant.IS_YESNO_NO;
        String npSocialRlGridJSON = request.getParameter("npSocialRlGridJSON");
        List<SplRlPsnVO> SplRlPsnVOList = new ArrayList<SplRlPsnVO>();

        if (null != npSocialRlGridJSON) {
            SplRlPsnVOList = JSON.parseArray(npSocialRlGridJSON, SplRlPsnVO.class);
        }
        if (CollectionUtils.isEmpty(SplRlPsnVOList)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, "请维护主要人员信息.");
        } else {
            List<SplRlPsnVO> newRlPsnVoList = new ArrayList<SplRlPsnVO>();
            for (SplRlPsnVO splRlPsnVO : SplRlPsnVOList) {
                if (StringUtils.isNotEmpty(splRlPsnVO.getRlTypCd()) && BaseConstant.IS_YESNO_YES_STR.equals(splRlPsnVO.getRlTypCd())) {
                    newRlPsnVoList.add(splRlPsnVO);
                }
            }
            boolean checkIsNewVo = true;
            List<SplBiApplyRlPsnVO> applyRlPsnVOs = null;
            //判断是否存在变更的主要联系人数据
            if (StringUtils.isNotEmpty(applyId)) {
                applyRlPsnVOs = this.splBscInfoApplyService.getSplRlPsnApplyById(null, applyId);
                if (CollectionUtils.isNotEmpty(applyRlPsnVOs)) {
                    checkIsNewVo = false;
                }
            }
            //不存在主要变更联系人信息
            if (checkIsNewVo) {
                applyRlPsnVOs = new ArrayList<SplBiApplyRlPsnVO>();
                for (SplRlPsnVO splRlPsnVO : oldSplRlPsnVOList) {
                    //将默认主要联系人信息保存到变更信息表中
                    if (StringUtils.isNotEmpty(splRlPsnVO.getRlTypCd()) && BaseConstant.IS_YESNO_YES_STR.equals(splRlPsnVO.getRlTypCd())) {
                        applyRlPsnVOs.add(setSplBiApplyRlPsnVo(splRlPsnVO, BaseConstant.IS_YESNO_NO));
                    }
                }
            }

            //判断是否有变化，有变化的话更新内容
            if (applyRlPsnVOs.size() > 0) {
                for (SplBiApplyRlPsnVO vo : applyRlPsnVOs) {
                    if (CollectionUtils.isNotEmpty(newRlPsnVoList)) {
                        for (SplRlPsnVO newRlPsnVo : newRlPsnVoList) {
                            if ((!checkIsNewVo && vo.getId().equals(newRlPsnVo.getApplyPsnId()))
                                    || (checkIsNewVo && StringUtils.isNotEmpty(vo.getRlTypCd())
                                    && StringUtils.isNotEmpty(newRlPsnVo.getRlTypCd())
                                    && vo.getRlTypCd().equals(newRlPsnVo.getRlTypCd()))) {
                                //当默认的主要联系人关联类型相同时，判断是否发生变化
                                //判断是否发生变化，
                                if (StringUtils.isEmpty(vo.getRlNm()) || !vo.getRlNm().equals(newRlPsnVo.getRlNm())) {
                                    vo.setRlNm(newRlPsnVo.getRlNm());
                                    modifyState = BaseConstant.IS_YESNO_YES;
                                }
                                if (StringUtils.isEmpty(vo.getCertTypCd()) || !vo.getCertTypCd().equals(newRlPsnVo.getCertTypCd())) {
                                    vo.setCertTypCd(newRlPsnVo.getCertTypCd());
                                    modifyState = BaseConstant.IS_YESNO_YES;
                                }
                                if (StringUtils.isEmpty(vo.getCertNo()) || !vo.getCertNo().equals(newRlPsnVo.getCertNo())) {
                                    vo.setCertNo(newRlPsnVo.getCertNo());
                                    modifyState = BaseConstant.IS_YESNO_YES;
                                }
                                if (StringUtils.isEmpty(vo.getRlTypCd()) || !vo.getRlTypCd().equals(newRlPsnVo.getRlTypCd())) {
                                    vo.setRlTypCd(newRlPsnVo.getRlTypCd());
                                    modifyState = BaseConstant.IS_YESNO_YES;
                                }
                                if (StringUtils.isEmpty(vo.getTel()) || !vo.getTel().equals(newRlPsnVo.getTel())) {
                                    vo.setTel(newRlPsnVo.getTel());
                                    modifyState = BaseConstant.IS_YESNO_YES;
                                }
                                newRlPsnVoList.remove(newRlPsnVo);
                                break;
                            }
                        }
                    }
                }
            }

            if (CollectionUtils.isNotEmpty(newRlPsnVoList)) {
                for (SplRlPsnVO newRlPsnVo : newRlPsnVoList) {
                    applyRlPsnVOs.add(setSplBiApplyRlPsnVo(newRlPsnVo, BaseConstant.IS_YESNO_YES));
                    modifyState = BaseConstant.IS_YESNO_YES;
                }
            }

            map.put("applyRlPsnVos", applyRlPsnVOs);
            map.put("isChngBaseData", modifyState);

        }
        return map;
    }

    /**
     * 将重要联系人信息复制的联系人变更中
     *
     * @param splRlPsnVO
     * @param isNewStatus 状态是否新增
     * @return
     */
    private SplBiApplyRlPsnVO setSplBiApplyRlPsnVo(SplRlPsnVO splRlPsnVO, int isNewStatus) {
        SplBiApplyRlPsnVO vo = new SplBiApplyRlPsnVO();
        vo.setSplRlPsnId(splRlPsnVO.getId());
        vo.setRlNm(splRlPsnVO.getRlNm());
        vo.setCertTypCd(splRlPsnVO.getCertTypCd());
        vo.setCertNo(splRlPsnVO.getCertNo());
        vo.setRlTypCd(splRlPsnVO.getRlTypCd());
        vo.setTel(splRlPsnVO.getTel());
        vo.setIsDefault(splRlPsnVO.getIsDefault());
        vo.setRlRem(splRlPsnVO.getRlRem());
        vo.setIsDel(splRlPsnVO.getIsDel());
        vo.setCrtUsrId(splRlPsnVO.getCrtUsrId());
        vo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
        if (BaseConstant.IS_YESNO_YES != isNewStatus) {
            vo.setMdfUsrIdB(splRlPsnVO.getMdfUsrId());
            vo.setMdfTmB(splRlPsnVO.getMdfTm());
            vo.setIsDelB(splRlPsnVO.getIsDel());
            vo.setCrtTmB(splRlPsnVO.getCrtTm());
            vo.setCrtUsrIdB(splRlPsnVO.getCrtUsrId());
            vo.setRlNmB(splRlPsnVO.getRlNm());
            vo.setCertTypCdB(splRlPsnVO.getCertTypCd());
            vo.setCertNoB(splRlPsnVO.getCertNo());
            vo.setRlTypCdB(splRlPsnVO.getRlTypCd());
            vo.setTelB(splRlPsnVO.getTel());
        }
        return vo;
    }

    //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13

    /**
     * 获取变更数据，并保存流程审核权限数据
     *
     * @param request
     * @param applyFlowCdAndNmMap 需要发起变更审核的流程权限配置
     * @return
     *//*
    private List<SplBiApplyFlowRlVO> getApplyFlowRlVo(HttpServletRequest request,Map<String,String> applyFlowCdAndNmMap) {
        String applyId = request.getParameter("applyId");
        String id = request.getParameter("id");
        //判断当前供应商是否存在变更审核中流程
        boolean flag = this.getFlowingState(Long.valueOf(id));

        //获取原有的流程信息(重卡提前放款及准时放款)
        List<SysBizFlowRlVO> oldVoList = this.getOldSysBizFlowRlVo(request, flag, applyFlowCdAndNmMap);
        //新需走变更的流程
        List<SysBizFlowRlVO> newVoList = null;

        //新获取的流程权限配置信息
        List<SysBizFlowRlVO> listNewVos = this.getRequestSysBizFlowRLParam(request);
        if (CollectionUtils.isNotEmpty(listNewVos) && CollectionUtils.isMapNotEmpty(applyFlowCdAndNmMap)) {
            newVoList = new ArrayList<>(listNewVos.size());
            //获取最新变更的流程数据，并删除掉
            Iterator<SysBizFlowRlVO> sysBizFlowRlVOIterator = listNewVos.iterator();
            while (sysBizFlowRlVOIterator.hasNext()){
                SysBizFlowRlVO vo = sysBizFlowRlVOIterator.next();
                if(applyFlowCdAndNmMap.containsKey(vo.getPDefKey())){
                    newVoList.add(vo);
                    sysBizFlowRlVOIterator.remove();
                }
            }
            if(CollectionUtils.isNotEmpty(oldVoList)){
                listNewVos.addAll(oldVoList);
            }
        }

        //保存无需走变更的流程权限及历史数据修改
        if(CollectionUtils.isNotEmpty(listNewVos)){
            this.saveBiApplyFlow(listNewVos, flag);
        }
        //获取变更流程的变更记录
        List<SplBiApplyFlowRlVO> applyFlowRlVOList = this.getApplyinfFlowInfoVo(applyId, newVoList, oldVoList,applyFlowCdAndNmMap);
        return applyFlowRlVOList ;
    }*/

    //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
    /**
     * 获取发生变化的流程权限历史表
     *
     * @param applyId
     * @param newSysBizFlowRlList 新修改流程权限配置信息
     * @param oldSysBizFlowRlList 旧流程权限配置信息
     * @param applyFlowCdAndNmMap 需要发起变更流程的流程权限配置CODE-NAME Map
     * @return
     *//*
    private List<SplBiApplyFlowRlVO> getApplyinfFlowInfoVo(String applyId, List<SysBizFlowRlVO> newSysBizFlowRlList,
                                                           List<SysBizFlowRlVO> oldSysBizFlowRlList,Map<String,String> applyFlowCdAndNmMap) {
        //流程变更历史记录
        List<SplBiApplyFlowRlVO> applyFlowRlVOs = null ;

        //已存在流程变更历史记录
        Map<String,SplBiApplyFlowRlVO> pDefKeyApplyFlowRlMap = null ;
        if (StringUtils.isNotBlank(applyId)) {
            List<SplBiApplyFlowRlVO> lists = this.splBscInfoApplyService.getSplApplyFlow(Long.valueOf(applyId));
            if (CollectionUtils.isNotEmpty(lists)) {
                pDefKeyApplyFlowRlMap = new HashMap<>(lists.size()) ;
                for(SplBiApplyFlowRlVO splBiApplyFlowRlVO : lists){
                    pDefKeyApplyFlowRlMap.put(splBiApplyFlowRlVO.getPDefKey(),splBiApplyFlowRlVO);
                }
            }
        }
        //新 - 流程KEY与流程权限信息关系MAP
        Map<String,SysBizFlowRlVO> newDefKeyAndBizFlowRlMap = null ;
        if(CollectionUtils.isNotEmpty(newSysBizFlowRlList)){
            newDefKeyAndBizFlowRlMap = new HashMap<>(newSysBizFlowRlList.size());
            for(SysBizFlowRlVO flowRlVO : newSysBizFlowRlList){
                newDefKeyAndBizFlowRlMap.put(flowRlVO.getPDefKey(),flowRlVO);
            }
        }
        //旧 - 流程KEY与流程权限信息关系MAP
        Map<String,SysBizFlowRlVO> oldDefKeyAndBizFlowRlMap = null ;
        if(CollectionUtils.isNotEmpty(oldSysBizFlowRlList)){
            oldDefKeyAndBizFlowRlMap = new HashMap<>(oldSysBizFlowRlList.size());
            for(SysBizFlowRlVO flowRlVO : oldSysBizFlowRlList){
                oldDefKeyAndBizFlowRlMap.put(flowRlVO.getPDefKey(),flowRlVO);
            }
        }
        //判断是否发生变化
        //1、当新，老数据都有，并且状态和数量发生了变化，进行重新赋值
        if(CollectionUtils.isMapNotEmpty(applyFlowCdAndNmMap)){
            for(Map.Entry<String,String> entry : applyFlowCdAndNmMap.entrySet()){
                String pDefKey = entry.getKey();
                //新流程权限信息
                SysBizFlowRlVO newSysBizFlowRlVO = null ;
                if(CollectionUtils.isMapNotEmpty(newDefKeyAndBizFlowRlMap) && newDefKeyAndBizFlowRlMap.containsKey(pDefKey)){
                    newSysBizFlowRlVO = newDefKeyAndBizFlowRlMap.get(pDefKey);
                }
                //旧流程权限信息
                SysBizFlowRlVO oldSysBizFlowRlVO = null ;
                if(CollectionUtils.isMapNotEmpty(oldDefKeyAndBizFlowRlMap) && oldDefKeyAndBizFlowRlMap.containsKey(pDefKey)){
                    oldSysBizFlowRlVO = oldDefKeyAndBizFlowRlMap.get(pDefKey);
                }

                //判断是否发生变化
                if (CollectionUtils.isEmpty(applyFlowRlVOs)) {
                    applyFlowRlVOs = new ArrayList<>(4);
                }

                SplBiApplyFlowRlVO applyFlowRlVO = null ;
                if(CollectionUtils.isMapNotEmpty(pDefKeyApplyFlowRlMap) && pDefKeyApplyFlowRlMap.containsKey(pDefKey)){
                    applyFlowRlVO = pDefKeyApplyFlowRlMap.get(pDefKey);
                    applyFlowRlVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                    applyFlowRlVO.setMdfTm(new Date());
                }else{
                    applyFlowRlVO = new SplBiApplyFlowRlVO();
                    applyFlowRlVO.setCrtTm(new Date());
                    applyFlowRlVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                }

                if(null != newSysBizFlowRlVO){
                    if(null != oldSysBizFlowRlVO){
                        //jiangzg 2018-8-20 18:03:26 修改
                        if (StringUtils.isEmpty(newSysBizFlowRlVO.getFlowNum())
                                || !newSysBizFlowRlVO.getFlowNum().equals(oldSysBizFlowRlVO.getFlowNum())
                                || StringUtils.isEmpty(newSysBizFlowRlVO.getExpireUncardNum())
                                || !newSysBizFlowRlVO.getExpireUncardNum().equals(oldSysBizFlowRlVO.getExpireUncardNum())) {
                            //判断是否发生变化
                            //修改后
                            applyFlowRlVO.setDataId(newSysBizFlowRlVO.getDataId());
                            applyFlowRlVO.setTabNm(newSysBizFlowRlVO.getTabNm());
                            applyFlowRlVO.setPDefKey(newSysBizFlowRlVO.getPDefKey());
                            applyFlowRlVO.setIsDel(newSysBizFlowRlVO.getIsDel());
                            applyFlowRlVO.setFlowNum(newSysBizFlowRlVO.getFlowNum());
                            applyFlowRlVO.setExpireUncardNum(newSysBizFlowRlVO.getExpireUncardNum());
                            //修改前
                            applyFlowRlVO.setIsDelB(oldSysBizFlowRlVO.getIsDel());
                            applyFlowRlVO.setTabNmB(oldSysBizFlowRlVO.getTabNm());
                            applyFlowRlVO.setPDefKeyB(oldSysBizFlowRlVO.getPDefKey());
                            applyFlowRlVO.setFlowNumB(oldSysBizFlowRlVO.getFlowNum());
                            applyFlowRlVO.setCrtTmB(oldSysBizFlowRlVO.getCrtTm());
                            applyFlowRlVO.setCrtUsrIdB(oldSysBizFlowRlVO.getCrtUsrId());
                            applyFlowRlVO.setMdfTmB(oldSysBizFlowRlVO.getMdfTm());
                            applyFlowRlVO.setMdfUsrIdB(oldSysBizFlowRlVO.getMdfUsrId());
                            applyFlowRlVO.setExpireUncardNumB(oldSysBizFlowRlVO.getExpireUncardNum());

                            applyFlowRlVO.setSysBizFlowRlId(oldSysBizFlowRlVO.getId());

                        }
                    }else{
                        //判断是否发生变化
                        applyFlowRlVO.setDataId(newSysBizFlowRlVO.getDataId());
                        applyFlowRlVO.setTabNm(newSysBizFlowRlVO.getTabNm());
                        applyFlowRlVO.setPDefKey(newSysBizFlowRlVO.getPDefKey());
                        applyFlowRlVO.setIsDel(newSysBizFlowRlVO.getIsDel());
                        applyFlowRlVO.setFlowNum(newSysBizFlowRlVO.getFlowNum());
                        //TODO 旧数据就当是删除？
                        applyFlowRlVO.setIsDelB(BaseConstant.IS_YESNO_YES);
                        applyFlowRlVO.setFlowNumB(0);
                        applyFlowRlVO.setExpireUncardNum(newSysBizFlowRlVO.getExpireUncardNum());
                        applyFlowRlVO.setExpireUncardNumB(0);
                    }
                }else{
                    if(null != oldSysBizFlowRlVO){
                        //旧数据
                        applyFlowRlVO.setIsDelB(oldSysBizFlowRlVO.getIsDel());
                        applyFlowRlVO.setFlowNumB(oldSysBizFlowRlVO.getFlowNum());
                        applyFlowRlVO.setDataId(oldSysBizFlowRlVO.getDataId());
                        applyFlowRlVO.setTabNmB(oldSysBizFlowRlVO.getTabNm());
                        applyFlowRlVO.setPDefKeyB(oldSysBizFlowRlVO.getPDefKey());
                        //新数据就当删除处理
                        applyFlowRlVO.setIsDel(BaseConstant.IS_YESNO_YES);
                        applyFlowRlVO.setFlowNum(0);
                        applyFlowRlVO.setExpireUncardNum(0);
                        applyFlowRlVO.setExpireUncardNumB(oldSysBizFlowRlVO.getExpireUncardNum());
                    }
                }
                applyFlowRlVOs.add(applyFlowRlVO);
            }
        }
        return applyFlowRlVOs;
    }*/
    //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
    /**
     * 修改流程权限信息
     *
     * @param list
     * @param flag
     * @return
     * @throws
     * @author jiangzg 2018-9-11 13:51:51 mdf
     *//*
    private void saveBiApplyFlow(List<SysBizFlowRlVO> list, boolean flag) throws BaseException {
        try {
            if (flag) {
                //插入流程中的数据信息
                this.splBscInfoApplyService.batchAddForFlow(list);
            } else {
                this.splBscInfoApplyService.batchAdd(list);
            }

        } catch (BaseException ex) {
            BaseLogUtils.info(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(list) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            BaseLogUtils.error(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(list) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
    }*/

    //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
    /**
     * 获取已存在的重卡提前放款流程及准时放款信息
     *
     * @param request
     * @param flag 是否有流程信息修改
     * @param flowAuthMap 经销商流程权限配置Map
     * @return
     * @author jiangzg 2018-9-10 15:41:32 mdf
     * @throws BaseException
     *//*
    private List<SysBizFlowRlVO> getOldSysBizFlowRlVo(HttpServletRequest request, boolean flag , Map<String,String> flowAuthMap) throws BaseException {
        List<SysBizFlowRlVO> sysBizFlowRlVOS = null ;
        String id = request.getParameter("id");
        String tabNm = request.getParameter("flowTabNm");

        SysBizFlowRlQueryCondition qc = new SysBizFlowRlQueryCondition();
        qc.setDataId(Long.valueOf(id));
        qc.setTabNm(tabNm);
        if (flag) {
            qc.setIsDel(SysBizFlowRlConstant.CODE_FLOW_SAVE_STATUS);
        } else {
            qc.setIsDel(BaseConstant.IS_YESNO_NO);
        }
        List<SysBizFlowRlVO> list = this.splBscInfoApplyService.searchSysBizFlowRlList(qc);
        if (CollectionUtils.isEmpty(list)) {
            qc.setIsDel(BaseConstant.IS_YESNO_NO);
            list = this.splBscInfoApplyService.searchSysBizFlowRlList(qc);
        }
        if (CollectionUtils.isNotEmpty(list) && CollectionUtils.isMapNotEmpty(flowAuthMap)) {
            sysBizFlowRlVOS = new ArrayList<>(4);
            for (SysBizFlowRlVO flowRlVo : list) {
                if(flowAuthMap.containsKey(flowRlVo.getpDefKey())){
                    sysBizFlowRlVOS.add(flowRlVo);
                }
            }
        }
        return sysBizFlowRlVOS;
    }*/

    //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13
    /**
     * 获取请求参数
     *
     * @param request
     * @return
     * @throws BaseException
     *//*
    private List<SysBizFlowRlVO> getRequestSysBizFlowRLParam(HttpServletRequest request) throws BaseException {
        List<SysBizFlowRlVO> list = null ;
        String dataId = request.getParameter("id");
        String tabNm = request.getParameter("flowTabNm");
        if (StringUtils.isEmpty(dataId) || StringUtils.isEmpty(tabNm)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, "请求参数不完整.");
        }
        String pDefKeyJSON = request.getParameter("pDefKey");
        if (StringUtils.isNotEmpty(pDefKeyJSON)) {
            String[] pDefKeyStr = pDefKeyJSON.split(";");
            if (pDefKeyStr.length > 0) {
                list = new ArrayList<>(pDefKeyStr.length);
                for (String pDefKey : pDefKeyStr) {
                    SysBizFlowRlVO sysBizFlowRlVO = new SysBizFlowRlVO();
                    sysBizFlowRlVO.setDataId(Long.valueOf(dataId));
                    sysBizFlowRlVO.setTabNm(tabNm);
                    sysBizFlowRlVO.setPDefKey(pDefKey);
                    String flowNum = request.getParameter("flowNum" + pDefKey);
                    if (StringUtils.isNotEmpty(flowNum)) {
                        sysBizFlowRlVO.setFlowNum(Integer.valueOf(flowNum));
                    }
                    String expireUncardNum = request.getParameter("expire" + pDefKey);
					if (StringUtils.isNotEmpty(expireUncardNum) && pDefKey.equalsIgnoreCase(SysBizFlowRlConstant.CODE_BIZ_FLOW_P_DEF_KEY_1)) {
						sysBizFlowRlVO.setExpireUncardNum(Integer.valueOf(expireUncardNum));
					}
                    String isOrCheckLimit = request.getParameter("isOrCheckLimit");
                    if(StringUtils.isEmpty(flowNum) && StringUtils.isNotEmpty(isOrCheckLimit)
                            && pDefKey.equalsIgnoreCase(SysBizFlowRlConstant.CODE_BIZ_FLOW_P_DEF_KEY_2)){
                        sysBizFlowRlVO.setFlowNum(Integer.valueOf(isOrCheckLimit));
                    }
                    sysBizFlowRlVO.setIsDel(BaseConstant.IS_YESNO_NO);
                    sysBizFlowRlVO.setCrtTm(new Date());
                    sysBizFlowRlVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    list.add(sysBizFlowRlVO);
                }
            }
        }
        return list;
    }*/

    /**
     * 判断当前供应商是否存在变更审核中流程
     *
     * @param dataId
     * @return
     */
    private boolean getFlowingState(Long dataId) throws BaseException {
        boolean flag = false;
        SysFlowSHQueryCondition flowQc = new SysFlowSHQueryCondition();
        List<Long> idList = new ArrayList<Long>();
        idList.add(dataId);
        flowQc.setDataIdList(idList);
        flowQc.setWordsInTheTable(SplInfoConstant.SPL_FLOW_S_H_SPL);
        flowQc.setSysCd(CurrentThreadContext.getCurrentSysCd());
        flowQc.setStatus(BaseConstant.IS_YESNO_YES);
        List<String> busTypList = new ArrayList<String>();
        busTypList.add(FlowConstant.FLOW_MODEL_TYP_SPL_AUTHORITH);
        flowQc.setBusTypList(busTypList);
        List<SysFlowSHDTO> flowSHList = this.splBscInfoApplyService.searchFlowSHList(flowQc);
        if (CollectionUtils.isNotEmpty(flowSHList)) {
            String audStsCd = flowSHList.get(0).getAudStsCd();
            if (audStsCd.equals(FlowConstant.FLOW_CHECK_STATE_IN) || audStsCd.equals(FlowConstant.FLOW_CHECK_STATE_REJECT)) {
                flag = true;
            }
        }
        return flag;
    }


    /**
     * 获取供应商参数信息
     *
     * @param request 请求参数
     * @param id 经销商ID
     * @param oldSplInfoVO 经销商信息
     * @param flag 是否变更
     * @return
     * @throws BaseException
     * @author jiangzg 2018-9-10 17:47:31 mdf
     */
    private SplInfoVO getRequestParamForPrdSpl(HttpServletRequest request, Long id,SplInfoVO oldSplInfoVO,boolean flag) throws BaseException {

        SplInfoVO prdSplInfoVO = null ;
        if(null != oldSplInfoVO){
            prdSplInfoVO = oldSplInfoVO ;
        }
        if(null == prdSplInfoVO){
            //通过主键id 查询供应商信息
            prdSplInfoVO = this.splBscInfoApplyService.selectSplInfoVOById(id);
        }

        String mfrIds = request.getParameter("mfrIds");//所属厂商
        List<Long> mfrIdsList = new ArrayList<Long>();
        if (StringUtils.isNotBlank(mfrIds)) {
            String[] mfrIdsStr = mfrIds.split(";");
            if (mfrIdsStr.length > 0) {
                for (String str : mfrIdsStr) {
                    mfrIdsList.add(Long.valueOf(str));
                }
            }
        }
        String rebPct = request.getParameter("rebPct");//供应商返利比例
        String splNm = request.getParameter("splNm");//供应商名称
        String taxRegNo = request.getParameter("taxRegNo");//税务登记号
        String splTel = request.getParameter("splTel");//联系方式
        String splFax = request.getParameter("splFax");//供应商传真
        String corpTypCd = request.getParameter("corpTypCd");//企业性质
        String bizLicNo = request.getParameter("bizLicNo");//营业执照注册号
        String regDt = request.getParameter("regDt");//成立日期
        String expDt = request.getParameter("expDt");//有效日期
        String orgCode = request.getParameter("orgCode");//组织机构代码号
        String regCapAmt = request.getParameter("regCapAmt");//注册资本
        String regCapUntCd = request.getParameter("regCapUntCd");//注册资本单位
        String paidCapAmt = request.getParameter("paidCapAmt");//实收资本
        String paidCapUntCd = request.getParameter("paidCapUntCd");//实收资本单位
        String isBuyBack = request.getParameter("isBuyBack");//是否回购
        String regAddr = request.getParameter("regAddr");//注册地址
        String rgnPrCd = request.getParameter("rgnPrCd");//区域 省CD
        String rgnCyCd = request.getParameter("rgnCyCd");//区域 市CD
        String postAddr = request.getParameter("postAddr");//供销商地址
        String websit = request.getParameter("websit");//供销商网址
        String bizScope = request.getParameter("bizScope");//经营范围
        String othInfoCd = request.getParameter("othInfoCd");//其他信息
        String zipNo = request.getParameter("zipNo");//其他信息

        String splLvlCd = request.getParameter("splLvlCd");//供应商级别
        String bilWayCd = request.getParameter("bilWayCd");//开票资质
        String prjLvlCd = request.getParameter("prjLvlCd");//供应商立项级别

        String splAttrCd = prdSplInfoVO.getSplAttrCd();//供应商属性

        String tkBrCd = request.getParameter("tkBrCd");//卡车品牌

        String newCarTyp = request.getParameter("newCarTyp");
        String usedCarTyp = request.getParameter("usedCarTyp");

        String succ = request.getParameter("succ");

        String ownerCd = request.getParameter("ownerCd");//公司归属

        List<String> buOrgCdList = null ;
        //经销商经营类型数据字典
        List<SysDictionaryDTO> searchGroup = this.sysDictionaryApiService.searchGroup(WebBaseConstant.SPL_SYS_CD, WebBaseConstant.SYS_P_ORG_CD,WebBaseConstant.SPL_PROP_CODE_GRP_CD );
        Map<String,String> propTypCdAndBuOrgCd = null ;
        if(CollectionUtils.isNotEmpty(searchGroup)){
            propTypCdAndBuOrgCd = new HashMap<>(searchGroup.size());
            for(SysDictionaryDTO sysDictionaryDTO : searchGroup){
                propTypCdAndBuOrgCd.put(sysDictionaryDTO.getCode(),sysDictionaryDTO.getCodeDesc());
            }
        }

        //供应商经营类型
        List<String> propTypCdList = new ArrayList<String>();
        if(StringUtils.isNotEmpty(newCarTyp)){
            String[] newCarTypCdStr = newCarTyp.split(";");
            if(newCarTypCdStr.length > 0){
                for (String newCarTypCd : newCarTypCdStr) {
                    propTypCdList.add(newCarTypCd);
                }
            }
        }
        if(StringUtils.isNotEmpty(usedCarTyp)){
            String[] usedCarTypCdStr = usedCarTyp.split(";");
            if(usedCarTypCdStr.length > 0){
                for (String usedCarTypCd : usedCarTypCdStr) {
                    propTypCdList.add(usedCarTypCd);
                }
            }
        }

        if(CollectionUtils.isNotEmpty(propTypCdList) ){
            buOrgCdList = new ArrayList<>();
            for (String typCd : propTypCdList) {
                if(CollectionUtils.isMapNotEmpty(propTypCdAndBuOrgCd) && propTypCdAndBuOrgCd.containsKey(typCd)){
                    if(buOrgCdList.contains(propTypCdAndBuOrgCd.get(typCd))){
                        continue ;
                    }
                    buOrgCdList.add(propTypCdAndBuOrgCd.get(typCd));
                }
            }
        }

        List<String> tkBrCdList = new ArrayList<String>();
        if (StringUtils.isNotEmpty(tkBrCd)) {
            String[] brCdsStr = tkBrCd.split(";");
            if (brCdsStr.length > 0) {
                for (String str : brCdsStr) {
                    tkBrCdList.add(str);
                }
            }
        }
        String carBrCd = request.getParameter("carBrCd");//乘用车品牌
        List<String> carBrCdList = new ArrayList<String>();
        if (StringUtils.isNotEmpty(carBrCd)) {
            String[] brCdsStr = carBrCd.split(";");
            if (brCdsStr.length > 0) {
                for (String str : brCdsStr) {
                    carBrCdList.add(str);
                }
            }
        }
        String busBrCd = request.getParameter("busBrCd");//客车品牌
        List<String> busBrCdList = new ArrayList<String>();
        if (StringUtils.isNotEmpty(busBrCd)) {
            String[] brCdsStr = busBrCd.split(";");
            if (brCdsStr.length > 0) {
                for (String str : brCdsStr) {
                    busBrCdList.add(str);
                }
            }
        }
        String buOrgCds = request.getParameter("buOrgCds");//所属事业部
        List<String> buOrgCdsList = new ArrayList<String>();
        if (StringUtils.isNotEmpty(buOrgCds)) {
            String[] buOrgCdsStr = buOrgCds.split(";");
            if (buOrgCdsStr.length > 0) {
                for (String str : buOrgCdsStr) {
                    buOrgCdsList.add(str);
                }
            }
        }
        //TODO 2017-8-2 by YAOXIURONG
        String currentBuOrgCd = CurrentThreadContext.getCurrentBuOrgCd();
        Map<String, String> buOrgCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.CODE_SYS_BU_ORG_CD);
        if (buOrgCdMap.containsKey(currentBuOrgCd) && !buOrgCdsList.contains(currentBuOrgCd)) {
            buOrgCdsList.add(currentBuOrgCd);//在已有事业部基础上增加当前事业部
        }

        String prjTypCds = request.getParameter("prjTypCds");//项目类型
        List<String> prjTypCdsList = new ArrayList<String>();
        if (StringUtils.isNotEmpty(prjTypCds)) {
            String[] prjTypCdsStr = prjTypCds.split(";");
            if (prjTypCdsStr.length > 0) {
                for (String str : prjTypCdsStr) {
                    prjTypCdsList.add(str);
                }
            }
        }
        String splTypCd = request.getParameter("splTypCd");
        if (StringUtils.isNotBlank(splTypCd)) {
            prdSplInfoVO.setSplTypCd(splTypCd);
            if ("1".equalsIgnoreCase(splTypCd)) {
                String agtSec = request.getParameter("agtSec");
                String agtThd = request.getParameter("agtThd");
                String bscTaskQty = request.getParameter("bscTaskQty");
                String entDepAmt = request.getParameter("entDepAmt");
                String prdMaxValAmt = request.getParameter("prdMaxValAmt");
                if (StringUtils.isNotBlank(agtSec)) {
                    prdSplInfoVO.setAgtSec(agtSec);
                }
                if (StringUtils.isNotBlank(agtThd)) {
                    prdSplInfoVO.setAgtThd(agtThd);
                }
                if (StringUtils.isNotBlank(bscTaskQty)) {
                    prdSplInfoVO.setBscTaskQty(Integer.valueOf(bscTaskQty));
                }
                if (StringUtils.isNotBlank(entDepAmt)) {
                    prdSplInfoVO.setEntDepAmt(Double.valueOf(entDepAmt.trim()));
                }
                if (StringUtils.isNotBlank(prdMaxValAmt)) {
                    prdSplInfoVO.setPrdMaxValAmt(Double.valueOf(prdMaxValAmt.trim()));
                }
            } else {
                prdSplInfoVO.setAgtSec("");
                prdSplInfoVO.setAgtThd("");
                prdSplInfoVO.setBscTaskQty(0);
                prdSplInfoVO.setEntDepAmt(0d);
                prdSplInfoVO.setPrdMaxValAmt(0d);
            }
        }
        String coopDt = request.getParameter("coopDt");
        if (StringUtils.isNotEmpty(coopDt)) {
            prdSplInfoVO.setCoopDt(DateUtils.formatStringToDate(coopDt, DateUtils.YYYY_MM_DD));
        }
        //增加供应商属性判断
        if (StringUtils.isNotEmpty(splAttrCd) && CustomerConstant.CST_TYP_CD_NP.equals(splAttrCd)) {
            if (StringUtils.isBlank(splNm)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "姓名不能为空!");
            }
            if (StringUtils.isBlank(bizLicNo)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "证件号不能为空!");
            }

            if (StringUtils.isNotEmpty(splTel) && !StringUtils.isMobilePhoneAndFixedPhone(splTel)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "请输入正确的电话号码!");
            }

        } else {
            if (StringUtils.isBlank(splNm)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "供应商名称不能为空!");
            }

            if (StringUtils.isBlank(succ)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "统一社会信用代码不能为空!");
            }
            /*if (StringUtils.isBlank(bizLicNo)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "营业执照号不能为空!");
            }
            if (StringUtils.isBlank(taxRegNo)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "税务登记号不能为空!");
            }
            if (StringUtils.isBlank(orgCode)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "组织机构代码号不能为空!");
            }*/

            if (StringUtils.isNotEmpty(splTel) && !StringUtils.isMobilePhoneAndFixedPhone(splTel)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "请输入正确的电话号码!");
            }

            if (StringUtils.isBlank(regDt) || !DateUtils.isDate(regDt, DateUtils.YYYY_MM_DD)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "成立日期不能为空,并且为日期格式!");
            }

            if (DateUtils.formatStringToDate(regDt, DateUtils.YYYY_MM_DD).after(new Date())) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "成立日期不能大于当前日期!");
            }
            if (bilWayCd == null || StringUtils.isEmpty(bilWayCd)) {
                bilWayCd = "";
            }


            //联系人姓名电话不能为空
            //必须维护实际控制人
            String npSocialRlGridJSON = request.getParameter("npSocialRlGridJSON");
            List<SplRlPsnVO> rlPsnList = new ArrayList<SplRlPsnVO>();
            if (null != npSocialRlGridJSON) {
                rlPsnList = JSON.parseArray(npSocialRlGridJSON, SplRlPsnVO.class);
            }
            if (CollectionUtils.isEmpty(rlPsnList)) {
                throw new BaseException(BaseExceptionConstant.COMMON_0001, "请维护主要人员信息.");
            } else {
                //验证必填联系人是否填写start
                //供应商联系人类型
                Map<String, SysDictionaryDTO> splRLTypCdMap = this.sysDictionaryApiService.
                        searchGroupToObjMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(),
                                fl.spl.facade.framework.constant.DictionaryConstant.CODE_RL_TYP_CD);
                //必须维护联系人类型
                List<String> mustRlTypCdList = new ArrayList<String>();
                for (Entry<String, SysDictionaryDTO> entry : splRLTypCdMap.entrySet()) {
                    if (BaseConstant.IS_YESNO_YES == entry.getValue().getIsSysDef()) {
                        mustRlTypCdList.add(entry.getKey());
                    }
                }
                //前端传回的联系人类型集合
                List<String> rlTypCdList = new ArrayList<String>();
                for (SplRlPsnVO splRlPsnVO : rlPsnList) {
                    if (null != splRlPsnVO) {
                        rlTypCdList.add(splRlPsnVO.getRlTypCd());
                    }
                }
                for (String string : mustRlTypCdList) {
                    if (!rlTypCdList.contains(string)) {
                        throw new BaseException(BaseExceptionConstant.COMMON_0001, "请维护" + splRLTypCdMap.get(string).getCodeNm() + "信息。");
                    }
                }
                //验证必填联系人是否填写end

                //证件类型
                Map<String, String> certTypCdList = null;
                //this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.CODE_RL_TYP_CD);
                //必填联系人类型
                List<SysDictionaryDTO> mustAddRlPsnTypCds = this.sysDictionaryApiService.searchGroupAll(CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(),DictionaryConstant.CODE_RL_TYP_CD);
                List<String> mustAddRlPsns = null ;
                if(CollectionUtils.isNotEmpty(mustAddRlPsnTypCds)){
                    mustAddRlPsns = new ArrayList<>(mustAddRlPsnTypCds.size());
                    certTypCdList = new HashMap<>(mustAddRlPsnTypCds.size());
                    for(SysDictionaryDTO dto : mustAddRlPsnTypCds){
                        certTypCdList.put(dto.getCode(),dto.getCodeNm());
                        if(BaseConstant.IS_YESNO_YES == dto.getIsSysDef()){
                            mustAddRlPsns.add(dto.getCode());
                        }
                    }
                }

                for (SplRlPsnVO splRlPsnVO : rlPsnList) {
                    //验证输入项是否为空
                    if(mustAddRlPsns.contains(splRlPsnVO.getRlTypCd())){
                        if (StringUtils.isEmpty(splRlPsnVO.getRlNm())) {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "联系人姓名不能为空.");
                        } else if (StringUtils.isEmpty(splRlPsnVO.getRlTypCd())) {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "联系人类型不能为空.");
                        } else if (StringUtils.isEmpty(splRlPsnVO.getTel())) {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "联系人电话不能为空.");
                        } else if (StringUtils.isEmpty(splRlPsnVO.getCertTypCd())) {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "联系人证件类型不能为空.");
                        } else if (StringUtils.isEmpty(splRlPsnVO.getCertNo())) {
                            throw new BaseException(BaseExceptionConstant.COMMON_0001, "联系人证件号码不能为空.");
                        }
                    }

                    if (DictionaryConstant.CODE_CERT_TYP_CD_0.equals(splRlPsnVO.getCertTypCd())) {
                        String rlTypCdNu = certTypCdList.get(splRlPsnVO.getRlTypCd());
                        //this.validateIdCard(rlTypCdNu, splRlPsnVO.getRlNm(), splRlPsnVO.getCertNo());
                    }

                }
            }
            if (CollectionUtils.isNotEmpty(rlPsnList)) {
                for (SplRlPsnVO splRlPsnVO : rlPsnList) {
                    if (StringUtils.isEmpty(splRlPsnVO.getId())) {
                        splRlPsnVO.setCrtTm(new Date());
                        splRlPsnVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    } else {
                        splRlPsnVO.setMdfTm(new Date());
                        splRlPsnVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                    }
                }
            }
            prdSplInfoVO.setRlPsnList(rlPsnList);
        }

        if (StringUtils.isNotEmpty(rebPct)) {
            prdSplInfoVO.setRebPct(Double.valueOf(rebPct));
        } else {
            prdSplInfoVO.setRebPct(0d);
        }
        //商家APP 增加字段   by ZHAOYONG begin 20170829
        /*String isAuthCrdChk = request.getParameter("isAuthCrdChk");//是否有权查询征信（1：是，0：否）
        String limChkTms = request.getParameter("limChkTms");// 每日可查询征信次数
        if (StringUtils.isNotEmpty(isAuthCrdChk)) {
            prdSplInfoVO.setIsAuthCrdChk(Integer.valueOf(isAuthCrdChk));
        } else {
            prdSplInfoVO.setIsAuthCrdChk(0);
        }
        if (StringUtils.isNotEmpty(limChkTms)) {
            prdSplInfoVO.setLimChkTms(Integer.valueOf(limChkTms));
        }*/
        //else {
        //   throw new BaseException(BaseExceptionConstant.COMMON_0001, "每日可查询征信次数不能为空.");
        // }
        //商家APP 增加字段   by ZHAOYONG end 20170829
        splNm = org.springframework.util.StringUtils.replace(splNm, "（", "(");
        splNm = org.springframework.util.StringUtils.replace(splNm, "）", ")");

        if(!flag){
            prdSplInfoVO.setSplNm(splNm.trim());
        }
        if (StringUtils.isNotEmpty(taxRegNo) && !flag) {
            prdSplInfoVO.setTaxRegNo(taxRegNo.trim());
        }
        if (StringUtils.isNotEmpty(bizLicNo) && !flag) {
            prdSplInfoVO.setBizLicNo(bizLicNo.trim());
        }
        if (StringUtils.isNotEmpty(orgCode) && !flag) {
            prdSplInfoVO.setOrgCode(orgCode.trim());
        }
        //prdSplInfoVO.setPostAddr(postAddr);
        prdSplInfoVO.setWebsit(websit);
        //prdSplInfoVO.setBizScope(bizScope);
        prdSplInfoVO.setOthInfoCd(othInfoCd);
        prdSplInfoVO.setMfrIds(mfrIdsList);//所属厂商
        prdSplInfoVO.setSplTel(splTel);
        prdSplInfoVO.setSplFax(splFax);
        prdSplInfoVO.setCorpTypCd(corpTypCd);
        if (StringUtils.isNotEmpty(regDt)) {
            prdSplInfoVO.setRegDt(DateUtils.formatStringToDate(regDt, DateUtils.YYYY_MM_DD));
        }
        if (StringUtils.isNotEmpty(expDt)) {
            prdSplInfoVO.setExpDt(DateUtils.formatStringToDate(expDt, DateUtils.YYYY_MM_DD));
        }

        if (StringUtils.isNotBlank(regCapAmt)) {
            prdSplInfoVO.setRegCapAmt(Double.valueOf(regCapAmt.trim()));
        }
        prdSplInfoVO.setRegCapUntCd(regCapUntCd);
        if (StringUtils.isNotBlank(paidCapAmt)) {
            prdSplInfoVO.setPaidCapAmt(Double.valueOf(paidCapAmt.trim()));
        }
        prdSplInfoVO.setPaidCapUntCd(paidCapUntCd);
        if (null != isBuyBack) {
            prdSplInfoVO.setIsBuyBack(Integer.valueOf(isBuyBack.trim()));
        }
        if (StringUtils.isNotEmpty(regAddr)) {
            prdSplInfoVO.setRegAddr(regAddr.trim());
        }
        if (StringUtils.isNotEmpty(rgnPrCd)) {
            //prdSplInfoVO.setRgnPrCd(rgnPrCd.trim());
        }
        if (StringUtils.isNotEmpty(rgnCyCd)) {
            //prdSplInfoVO.setRgnCyCd(rgnCyCd.trim());
        }
        //经营范围
        if(StringUtils.isNotEmpty(bizScope)){
            ArrayList<String> bizScopeList = new ArrayList<>();
            String[] bizScopeCds = bizScope.split(";");
            for (String string : bizScopeCds) {
                bizScopeList.add(string);
            }
            prdSplInfoVO.setBizScopeCdList(bizScopeList);

        }

        prdSplInfoVO.setTkBrCdList(tkBrCdList);//卡车品牌
        prdSplInfoVO.setCarBrCdList(carBrCdList);//乘用车品牌
        prdSplInfoVO.setBusBrCdList(busBrCdList);//客车品牌
        //prdSplInfoVO.setBuOrgCds(buOrgCdsList);//所属事业部
        //prdSplInfoVO.setChkBusTypCdList(propTypCdList);//供应商经营类型
        //prdSplInfoVO.setBuOrgCds(buOrgCdsList);//所属事业部
        prdSplInfoVO.setPrjTypCds(prjTypCdsList);//项目类型
        prdSplInfoVO.setZipNo(zipNo);
        prdSplInfoVO.setSplLvlCd(splLvlCd);
        prdSplInfoVO.setPrjLvlCd(prjLvlCd);
        prdSplInfoVO.setBilWayCd(bilWayCd);
        //prdSplInfoVO.setOwnerCd(ownerCd);

        return prdSplInfoVO;
    }

    /**
     * 启动变更工作流程
     *
     * @param request
     * @param applyId
     */
    private FlowStartedDTO addFlowStart(HttpServletRequest request, Long splId, Long applyId, Map<String, Object> startParams) throws BaseException {
        String procDefKey = request.getParameter("procDefKey");
        String procDefId = request.getParameter("procDefId");
        String procNo = request.getParameter("procNo");
        FlowStartParamsDTO flowStartParamsDTO = new FlowStartParamsDTO();
        try {
            //流程定义Key和流程定义ID 如果是前端选择的则直接指定,如果不是则系统自动按照配置选择唯一一条记录,如果找不到会提示
            flowStartParamsDTO.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_IN);

            flowStartParamsDTO.setWordsInTheTable(SplInfoConstant.SPL_FLOW_S_H_SPL);
            //流程定义标识(必填)
            flowStartParamsDTO.setProcDefKey(procDefKey);
            //流程定义ID(必填)
            flowStartParamsDTO.setProcDefId(procDefId);
            //流程定义名称(自定义)
            flowStartParamsDTO.setProcNo(procNo);

            flowStartParamsDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
            //业务数据主键(必填)
            flowStartParamsDTO.setBusinessKey(applyId + "");
            flowStartParamsDTO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
            flowStartParamsDTO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
            flowStartParamsDTO.setSysCd(CurrentThreadContext.getCurrentSysCd());
            flowStartParamsDTO.setInitiator(String.valueOf(CurrentThreadContext.getCurrentUserId()));
            flowStartParamsDTO.setInitiatorNm(CurrentThreadContext.getCurrentUserName());
            flowStartParamsDTO.setProcPriority(FlowConstant.FLOW_PRIORITY_EMERGENCY);//优先级,可以在界面定义
            //业务类型(必填)-用于区分操作表标识
            flowStartParamsDTO.setBusinessType(FlowConstant.FLOW_BUSINESS_TYP_SPL_BSC_INFO);//确认用不用
            //模块类型(流程业务分类): 针对直接启动流程的业务使用
            flowStartParamsDTO.setModelTyp(FlowConstant.FLOW_MODEL_TYP_SPL_CHG);//需要和流程配置中的模块类型匹配
            flowStartParamsDTO.setStartParams(startParams);
            flowStartParamsDTO.setSearchDesc(CurrentThreadContext.getCurrentOrgDispNm() + "、供应商信息变更流程大字段参数未定!");
            DataResultDTO dataResultDTO = this.splBscInfoApplyService.addSplApplyFlowStart(flowStartParamsDTO);
            if (null != dataResultDTO && null != dataResultDTO.getData()) {
                FlowStartedDTO flowStartedDTO = (FlowStartedDTO) dataResultDTO.getData();
                return flowStartedDTO;
            }
        } catch (BaseException e) {
            BaseLogUtils.newWebLogger("启动变更工作流程失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);

            e.getStackTrace();
        } catch (Exception e) {
            BaseLogUtils.newWebLogger("启动变更工作流程失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
            e.getStackTrace();
        }
        return null;
    }

    /**
     * 保存供应商流程变更数据
     *
     * @param request
     * @param applyId
     * @throws BaseException
     */
    private void saveFlowSplFileList(HttpServletRequest request, Long applyId) throws BaseException {
        List<SysUlFilesRecVO> fileList = new ArrayList<SysUlFilesRecVO>();
        try {
            fileList = this.getFileList(request, applyId);
            if (CollectionUtils.isNotEmpty(fileList)) {
                boolean success = this.splBscInfoApplyService.batchAddSysUlFilesList(fileList);
                if (!success) {
                    BaseLogUtils.newWebLogger("新增供应商变更流程资料失败,DATA:" + JSON.toJSONString(fileList)).setLogOperType(LogOperEnum.RESP)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                            .setWarning(false)
                            .warn(LogExceptionEnum.COMMON_CODE_0002);
                } else {
                    BaseLogUtils.newWebLogger("新增供应商变更流程资料成功,DATA:" + JSON.toJSONString(fileList)).setLogOperType(LogOperEnum.RESP)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                            .setWarning(false)
                            .info();
                }
            }
        } catch (BaseException ex) {
            BaseLogUtils.newWebLogger("新增供应商变更流程资料失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            BaseLogUtils.newWebLogger("新增供应商变更流程资料失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
    }

    /**
     * 获取供应商变更流程资料信息
     *
     * @param request
     * @return
     * @throws BaseException
     */
    private List<SysUlFilesRecVO> getFileList(HttpServletRequest request, Long applyId) throws BaseException {
        String fileParams = request.getParameter("fileParams");//附件上传信息
        List<SysUlFilesRecVO> sysUlFilesRecVOList = new ArrayList<SysUlFilesRecVO>();
        //解析附件上传信息
        if (StringUtils.isNotEmpty(fileParams)) {
            List<Map<String, String>> fileParamsList = new ArrayList<Map<String, String>>();
            JSONArray arry = JSONArray.fromObject(fileParams);
            if (!(arry.size() > 0)) {
                return null;
            }
            for (int i = 0; i < arry.size(); i++) {
                net.sf.json.JSONObject jsonObject = arry.getJSONObject(i);
                Iterator<?> it = jsonObject.keys();
                HashMap<String, String> hMap = new HashMap<String, String>();
                while (it.hasNext()) {
                    String key = String.valueOf(it.next());
                    String value = (String) jsonObject.get(key);
                    hMap.put(key, value);
                }
                fileParamsList.add(hMap);
            }
            for (Map<String, String> map : fileParamsList) {
                SysUlFilesRecVO sysUlFilesRecVO = new SysUlFilesRecVO();
                sysUlFilesRecVO.setFileNm(map.get("fileNm"));
                sysUlFilesRecVO.setFilePath(map.get("filePath"));
                sysUlFilesRecVO.setAbsLocPath(PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_ROOT_PATH) + map.get("filePath"));
                sysUlFilesRecVO.setCrtTm(new Date());
                sysUlFilesRecVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                sysUlFilesRecVO.setPkId(applyId + "");
                sysUlFilesRecVO.setSysCd(map.get("sysCd"));
                sysUlFilesRecVO.setOrgCd(map.get("orgCd"));
                sysUlFilesRecVO.setCfgCd(map.get("cfgCd"));
                sysUlFilesRecVO.setCfgDtlCd(map.get("cfgDtlCd"));
                //默认验证状态:未验证
                sysUlFilesRecVO.setAudStsCd(PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_VALID_STATUS_CD_A));
                sysUlFilesRecVO.setTabNm(map.get("tabNm"));
                sysUlFilesRecVO.setIsDel(BaseConstant.IS_YESNO_NO);
                sysUlFilesRecVOList.add(sysUlFilesRecVO);
            }
        } else {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, "保存供应商变更流程资料信息,没有要保存的资料.");
        }
        return sysUlFilesRecVOList;
    }

    /**
     * 判断是否应该发起流程
     * @param request 请求参数
     * @param flowAuthConfigMap 经销商流程权限变更配置
     * @return
     * @author jiangzg 2018-9-10 15:43:39 mdf
     */
    private boolean getChangeStatus(HttpServletRequest request,Map<String,String> flowAuthConfigMap) throws BaseException {
        String id = request.getParameter("id");
        //通过主键id 查询供应商信息
        SplInfoVO oldSplInfoVo = this.splBscInfoApplyService.selectSplInfoVOById(Long.valueOf(id));
        //获取页面中供应商名称，税务登记号，营业执照，组织机构代码
        String splNm = request.getParameter("splNm");//供应商名称
        String taxRegNo = request.getParameter("taxRegNo");//税务登记号
        String bizLicNo = request.getParameter("bizLicNo");//营业执照注册号
        String orgCode = request.getParameter("orgCode");//组织机构代码号
        String fileParams = request.getParameter("fileParams"); //附件信息 add by jiangzg 2018-7-2 13:49:41
        String succ = request.getParameter("succ"); //统一社会信用代码
        String ownerCd = request.getParameter("ownerCd");//公司归属
        String rgnPrCd = request.getParameter("rgnProvCd");//区域 省CD
        String rgnCyCd = request.getParameter("rgnCityCd");//区域 市CD
        String postAddr = request.getParameter("postAddr");//办公地址
        String newCarTyp = request.getParameter("newCarTyp");//经营类型(新车)
        String usedCarTyp = request.getParameter("usedCarTyp");// 经营类型(二手车)
        boolean status = false;
        //判断主表信息是否为空，有变更时将基本数据信息变更状态为1
        if (StringUtils.isNotEmpty(splNm.trim())) {
            if (!splNm.trim().equals(oldSplInfoVo.getSplNm())) {
                oldSplInfoVo.setSplNm(splNm);
                status = true;
            }
        }
        if (StringUtils.isNotEmpty(taxRegNo)) {
            if (!taxRegNo.trim().equals(oldSplInfoVo.getTaxRegNo())) {
                oldSplInfoVo.setTaxRegNo(taxRegNo);
                status = true;
            }
        }

        if (StringUtils.isNotEmpty(bizLicNo)) {
            if (!bizLicNo.trim().equals(oldSplInfoVo.getBizLicNo())) {
                oldSplInfoVo.setBizLicNo(bizLicNo);
                status = true;
            }
        }
        if (StringUtils.isNotEmpty(orgCode)) {
            if (!orgCode.trim().equals(oldSplInfoVo.getOrgCode())) {
                oldSplInfoVo.setOrgCode(orgCode);
                status = true;
            }
        }
        //判断主表信息是否为空，有变更时将基本数据信息变更状态为1
        if (StringUtils.isNotEmpty(succ.trim())) {
            if (!succ.trim().equals(oldSplInfoVo.getSucc())) {
                oldSplInfoVo.setSucc(succ);
                status = true;
            }
        }
        //判断"公司归属"是否变更
        if (StringUtils.isNotEmpty(ownerCd)) {
            if (!ownerCd.trim().equals(oldSplInfoVo.getOwnerCd())) {
                oldSplInfoVo.setOwnerCd(ownerCd);
                status = true;
            }
        } else if (StringUtils.isNotEmpty(oldSplInfoVo.getOwnerCd())) {
            status = true;
        }
        //判断"区域 省CD"是否变更
        if (StringUtils.isNotEmpty(rgnPrCd)) {
            if (!rgnPrCd.trim().equals(oldSplInfoVo.getRgnPrCd())) {
                oldSplInfoVo.setRgnPrCd(rgnPrCd);
                status = true;
            }
        } else if (StringUtils.isNotEmpty(oldSplInfoVo.getRgnPrCd())) {
            status = true;
        }
        //判断"区域 市CD"是否变更
        if (StringUtils.isNotEmpty(rgnCyCd)) {
            if (!rgnCyCd.trim().equals(oldSplInfoVo.getRgnCyCd())) {
                oldSplInfoVo.setRgnCyCd(rgnCyCd);
                status = true;
            }
        } else if (StringUtils.isNotEmpty(oldSplInfoVo.getRgnCyCd())) {
            status = true;
        }
        //判断"办公地址"是否变更
        if (StringUtils.isNotEmpty(postAddr)) {
            if (!postAddr.trim().equals(oldSplInfoVo.getPostAddr())) {
                oldSplInfoVo.setPostAddr(postAddr);
                status = true;
            }
        } else if (StringUtils.isNotEmpty(oldSplInfoVo.getPostAddr())) {
            status = true;
        }
        //判断"经营类型(新车)","经营类型(二手车)"是否变更
        List<String> propTypCdList = new ArrayList<String>();
        if(StringUtils.isNotEmpty(newCarTyp)){
            String[] newCarTypCdStr = newCarTyp.split(";");
            if(newCarTypCdStr.length > 0){
                for (String newCar : newCarTypCdStr) {
                    propTypCdList.add(newCar);
                }
            }
        }
        if(StringUtils.isNotEmpty(usedCarTyp)){
            String[] usedCarTypCdStr = usedCarTyp.split(";");
            if(usedCarTypCdStr.length > 0){
                for (String usedCar : usedCarTypCdStr) {
                    propTypCdList.add(usedCar);
                }
            }
        }
        if(CollectionUtils.isNotEmpty(propTypCdList) ){
            List<String> chkBusTypCdList = oldSplInfoVo.getChkBusTypCdList();
            if (CollectionUtils.isEmpty(chkBusTypCdList)) {
                status = true;
            } else {
                if (chkBusTypCdList.size() == propTypCdList.size()) {
                    for (String s : chkBusTypCdList) {
                        if (!propTypCdList.contains(s)) {
                            status = true;
                        }
                    }
                } else {
                    status = true;
                }
            }
        } else if (CollectionUtils.isNotEmpty(oldSplInfoVo.getChkBusTypCdList())) {
            status = true;
        }
        //通过主键id 查询已经上传的附件信息 add by jiangzg 2018-7-2 14:08:06
        if ( !status && StringUtils.isNotEmpty(fileParams)) {
            JSONArray arry = JSONArray.fromObject(fileParams);
            if (!(arry.size() > 0)) {
                status = false;
            }else{
                status = true;
            }
        }

        if (status) {
            this.splBscInfoApplyService.checkBscInfo(SplInfoVOTransform.toDTO(oldSplInfoVo), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
            return status;
        }
        //获取原主要联系人信息
        SplRlPsnQueryCondition qc = new SplRlPsnQueryCondition();
        qc.setSplId(Long.valueOf(oldSplInfoVo.getId()));
        List<SplRlPsnVO> oldPsnList = this.splBscInfoApplyService.searchSplRlPsnVOList(qc);

        //判断主要联系人信息是否发生变化
        String npSocialRlGridJSON = request.getParameter("npSocialRlGridJSON");
        List<SplRlPsnVO> newPsnList = new ArrayList<SplRlPsnVO>();
        if (null != npSocialRlGridJSON) {
            newPsnList = JSON.parseArray(npSocialRlGridJSON, SplRlPsnVO.class);
        }
        if (CollectionUtils.isEmpty(newPsnList)) {
            throw new BaseException(BaseExceptionConstant.COMMON_0001, "请维护主要人员信息.");
        } else {
            Map<Long, SplRlPsnVO> maps = new HashMap<>();
            //判断是否有变化，有变化的话更新内容
            for (SplRlPsnVO splRlPsnVO : oldPsnList) {
                /*if (StringUtils.isNotEmpty(splRlPsnVO.getIsDefault()) && BaseConstant.IS_YESNO_YES == splRlPsnVO.getIsDefault()) {
                    maps.put(splRlPsnVO.getId(), splRlPsnVO);
                }*/
                if (StringUtils.isNotEmpty(splRlPsnVO.getRlTypCd()) && BaseConstant.IS_YESNO_YES_STR.equals(splRlPsnVO.getRlTypCd())) {
                    maps.put(splRlPsnVO.getId(), splRlPsnVO);
                }
            }
            if (null != newPsnList && newPsnList.size() > 0) {
                for (SplRlPsnVO vo : newPsnList) {
                    //if (StringUtils.isNotEmpty(vo.getIsDefault()) && BaseConstant.IS_YESNO_YES == vo.getIsDefault()) {
                    if (StringUtils.isNotEmpty(vo.getRlTypCd()) && BaseConstant.IS_YESNO_YES_STR.equals(vo.getRlTypCd())) {
                        SplRlPsnVO psnVO = maps.get(vo.getId());
                        if (null != psnVO) {
                            //判断是否发生变化，
                            if (StringUtils.isBlank(vo.getRlNm()) || !vo.getRlNm().equals(psnVO.getRlNm())) {
                                return true;
                            } else if (StringUtils.isBlank(vo.getCertTypCd()) || !vo.getCertTypCd().equals(psnVO.getCertTypCd())) {
                                return true;
                            } else if (StringUtils.isBlank(vo.getCertNo()) || !vo.getCertNo().equals(psnVO.getCertNo())) {
                                return true;
                            } else if (StringUtils.isBlank(vo.getRlTypCd()) || !vo.getRlTypCd().equals(psnVO.getRlTypCd())) {
                                return true;
                            } else if (StringUtils.isBlank(vo.getTel()) || !vo.getTel().equals(psnVO.getTel())) {
                                return true;
                            }
                        } else {
                            return true;
                        }
                    }
                }
            }
        }

        //修改供应商变更页面流程权限变更  fengzuoxiang  2019-06-13

        //只有重卡事业部和总公司才可以修改
        /*if (SplBscInfoApplyConstant.SPL_ADMISSION_ORG_CD_0.equals(CurrentThreadContext.getCurrentBuOrgCd())
                || SplBscInfoApplyConstant.SPL_ADMISSION_ORG_CD_05.equals(CurrentThreadContext.getCurrentBuOrgCd())) {
            boolean flag = this.getFlowingState(Long.valueOf(id));
            //获取原有的流程权限配置信息
            List<SysBizFlowRlVO> oldVoList = this.getOldSysBizFlowRlVo(request, flag ,flowAuthConfigMap);
            Map<String,SysBizFlowRlVO> newBizFlowKeyAndNum = null ;
            List<SysBizFlowRlVO> listNewVos = this.getRequestSysBizFlowRLParam(request);
            if (CollectionUtils.isNotEmpty(listNewVos) && CollectionUtils.isMapNotEmpty(flowAuthConfigMap)) {
                newBizFlowKeyAndNum = new HashMap<>(4);
                //获取最新变更的流程数据，并删除掉
                for (SysBizFlowRlVO vo : listNewVos) {
                    if (flowAuthConfigMap.containsKey(vo.getpDefKey())) {
                        newBizFlowKeyAndNum.put(vo.getpDefKey(),vo);
                        break;
                    }
                }
            }

            if (CollectionUtils.isEmpty(oldVoList) && CollectionUtils.isMapNotEmpty(newBizFlowKeyAndNum)) {
                return true;
            } else if ( CollectionUtils.isMapEmpty(newBizFlowKeyAndNum) && CollectionUtils.isNotEmpty(oldVoList)) {
                return true;
            } else if (CollectionUtils.isMapNotEmpty(newBizFlowKeyAndNum) && CollectionUtils.isNotEmpty(oldVoList)) {
                for(SysBizFlowRlVO flowRlVO : oldVoList){
                    if(newBizFlowKeyAndNum.containsKey(flowRlVO.getpDefKey())
                            && !(newBizFlowKeyAndNum.get(flowRlVO.getpDefKey()).getFlowNum() == flowRlVO.getFlowNum())
                            && !(newBizFlowKeyAndNum.get(flowRlVO.getpDefKey()).getExpireUncardNum() == flowRlVO.getExpireUncardNum())){
                        return true ;
                    }
                }
            }
        }*/
        return false;
    }

    /**
     * 设置主要人员基本信息中关于字典项信息
     *
     * @param listVo
     */
    private void setPrdSplRlPsnDTOWithDicInfo(List<SplRlPsnVO> listVo, String sysCd, String orgCd) {
        if (CollectionUtils.isEmpty(listVo)){
            return;
        }
        Map<String, String> certTypCdMap = this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd, fl.spl.facade.framework.constant.DictionaryConstant.CODE_GRP_CERT_TYP_CD);
        Map<String, String> rlTypeCdMap = this.sysDictionaryApiService.searchGroupToMap(sysCd, orgCd, fl.spl.facade.framework.constant.DictionaryConstant.CODE_RL_TYP_CD);
        for (SplRlPsnVO vo : listVo) {
            //证件类型
            if (certTypCdMap.containsKey(vo.getCertTypCd())) {
                vo.setCertTypCdNm(certTypCdMap.get(vo.getCertTypCd()));
            }

            //人员类型
            if (rlTypeCdMap.containsKey(vo.getRlTypCd())) {
                vo.setRlTypCdNm(rlTypeCdMap.get(vo.getRlTypCd()));
            }
        }
    }

    /**
     * 封装必输联系人信息
     * @param voList
     */
    private List<SplRlPsnVO> setSplRlPsnList(List<SplRlPsnVO> voList){
        //证件类型
        List<KeyValueVO> certTypCdList = this.splBscInfoApplyService.searchCertTypCdList();
        //获取默认证件类型名称
        String defCodNm = "";
        for (KeyValueVO keyValueVO : certTypCdList) {
            if(keyValueVO.getKey().equals(SplInfoConstant.CODE_CERT_TYP_DEF_CD)){
                defCodNm = keyValueVO.getValue();
            }
        }
        //联系人类型
        List<KeyValueVO> rlTypCDList = this.splBscInfoApplyService.searchRlTypCdList();
        Map<String,SplRlPsnVO> map=new HashMap<String,SplRlPsnVO>();
        //查询出所有必输联系人信息
        if(null != rlTypCDList && rlTypCDList.size()>0) {
            for (KeyValueVO keyValueVO : rlTypCDList) {
                if(!(keyValueVO.getKey().equals(SplInfoConstant.SPL_RL_TYP_CD_ACTUAL_2) || keyValueVO.getKey().equals("10") ||keyValueVO.getKey().equals("11") || keyValueVO.getKey().equals("12") || keyValueVO.getKey().equals("13") ) ) {
                    SplRlPsnVO vo = new SplRlPsnVO();
                    vo.setRlTypCd(keyValueVO.getKey());
                    vo.setRlTypCdNm(keyValueVO.getValue());
                    vo.setCertTypCd(SplInfoConstant.CODE_CERT_TYP_DEF_CD);
                    vo.setCertTypCdNm(defCodNm);
                    vo.setIsDel(BaseConstant.IS_YESNO_NO);
                    vo.setIsDefault(BaseConstant.IS_YESNO_YES);
                    map.put(keyValueVO.getKey(), vo);
                }
            }
        }
        //判断修改的联系人信息中是否存在必输的联系人
        if(null != voList && voList.size()>0){
            //循环将已经存在的vo信息
            for (SplRlPsnVO splRlPsnVO : voList) {
                //如果存在必输联系人，将必输Map中联系人去除
                if(map.containsKey(splRlPsnVO.getRlTypCd())){
                    map.remove(splRlPsnVO.getRlTypCd());
                }
            }
        }else{//新增时或修改时无联系人信息，创建联系人
            voList=new ArrayList<SplRlPsnVO>();
        }
        //将去除重复后的必输联系人添加到联系人列表中
        if(null != map && map.size()>0){
            for (Map.Entry<String, SplRlPsnVO> entry : map.entrySet()) {
                voList.add(entry.getValue());
            }
        }
        return voList;
    }

    /**
     * 初始化经销商变更资料列表
     */
    @RequestMapping(value = "/initSplApplyFileInfoList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initSplApplyFileInfoList(HttpServletRequest request, HttpServletResponse response) {
        String applyId = request.getParameter("applyId");//客户ID
        String cfgCd = request.getParameter("cfgCd");//附件配置编号
        String tabNm = request.getParameter("tabNm");//附件对应表名
        String cfgOrgCd = request.getParameter("cfgOrgCd") ;
        String cfgSysCd = request.getParameter("cfgSysCd") ;
        String uploadSysCd = request.getParameter("uploadSysCd") ;
        SysUlFilesRecQueryCondition qc = new SysUlFilesRecQueryCondition();
        qc.setPkId(applyId);
        qc.setCfgCd(cfgCd);
        if(StringUtils.isNotEmpty(cfgSysCd)){
            qc.setSysCd(cfgSysCd);
        }else{
            qc.setSysCd(SplSystemConstant.SPL_SYS_CD);
        }
        if(StringUtils.isNotEmpty(cfgOrgCd)){
            qc.setOrgCd(cfgOrgCd);
        }else{
            qc.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
        }
        if(StringUtils.isNotEmpty(tabNm)){
            qc.setTabNm(tabNm);
        }
        qc.setIsDel(BaseConstant.IS_YESNO_NO);
        List<PrjFileInfoVO> list = this.getUploadFileList(qc,uploadSysCd);
        ListPageVO listPageVO = null ;
        if (CollectionUtils.isNotEmpty(list)) {
            listPageVO =  new ListPageVO<PrjFileInfoVO>(list, list.size());
        }else{
            listPageVO =  new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
        }
        BaseLogUtils.newWebLogger("数据DATA:"+JSON.toJSONString(listPageVO)).setLogOperType(LogOperEnum.RESP)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
        return listPageVO ;
    }

    /**
     * 配置的系统CODE可能与上传实际的系统CODE 不一样
     * @param condition 包含配置文件的系统CDOE
     * @param uploadSysCd 上传位置具体系统CODE
     * @return
     * @throws BaseException
     */
    private List<PrjFileInfoVO> getUploadFileList(SysUlFilesRecQueryCondition condition,String uploadSysCd) throws BaseException {
        //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(condition.getSysCd());//系统代码
        ulDatCfgQueryCondition.setOrgCd(condition.getOrgCd());
        ulDatCfgQueryCondition.setDataId(String.valueOf(condition.getPkId()));//业务主键
        ulDatCfgQueryCondition.setIsValid(BaseConstant.IS_YESNO_YES);
        ulDatCfgQueryCondition.setIsDel(BaseConstant.IS_YESNO_NO);
        List<String> cfgCdList = new ArrayList<>();
        cfgCdList.add(condition.getCfgCd());//配置编号
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
        List<SysUlDatCfgDTO> list = null ;
        List<SysUlFilesRecDTO> filesRecDTOS = null ;
        List<PrjFileInfoVO> voList = null;
        Map<String,SysUlFilesRecDTO> regxUlFileRecMap = null ;
        if(StringUtils.isEmpty(condition.getPkId())){
            list =this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
        }else{
            list = this.uploadApiService.searchSysUlDatCfgListByDataId(ulDatCfgQueryCondition);
        }
        /*if(condition.getSysCd().equalsIgnoreCase(uploadSysCd)){
            if(StringUtils.isEmpty(condition.getPkId())){
                list =this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
            }else{
                list = this.uploadApiService.searchSysUlDatCfgListByDataId(ulDatCfgQueryCondition);
            }
        }else{
            list =this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
            if(StringUtils.isEmpty(condition.getPkId())){
                SysUlFilesRecQueryCondition recQueryCondition = new SysUlFilesRecQueryCondition();
                recQueryCondition.setSysCd(uploadSysCd);
                recQueryCondition.setPkId(condition.getPkId());
                recQueryCondition.setIsDel(BaseConstant.IS_YESNO_NO);
                recQueryCondition.setCfgCd(condition.getCfgCd());
                recQueryCondition.setOrgCd(condition.getOrgCd());
                recQueryCondition.setTabNm(condition.getTabNm());
                filesRecDTOS = this.uploadApiService.searchSysUlFilesRecNoUrlPrefixList(recQueryCondition);
                if(CollectionUtils.isNotEmpty(filesRecDTOS)){
                    regxUlFileRecMap = new HashMap<>(filesRecDTOS.size());
                    for(SysUlFilesRecDTO recDTO : filesRecDTOS){
                        //设置路径
                        String filePath = recDTO.getFilePath();
                        if(StringUtils.isNotEmpty(filePath)){
                            String picServicePath = PropertiesCacheUtils.getProperty(cmm.comm.facade.upload.constant.UploadConstant.UPLOAD_SERVER_PATH);
                            //如果有HTTP开头说明是可以访问路径,无需干涉
                            if(!filePath.startsWith("http") && StringUtils.isNotEmpty(picServicePath)){
                                recDTO.setFilePath(picServicePath+filePath);
                            }
                        }
                        regxUlFileRecMap.put(recDTO.getCfgCd()+"_"+recDTO.getCfgDtlCd(),recDTO);
                    }
                }
            }
        }
*/
        if (CollectionUtils.isNotEmpty(list)) {
            Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
            voList = new ArrayList<>();
            PrjFileInfoVO vo;
            //设置路径
            String picServicePath = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_SERVER_PATH);
            for (SysUlDatCfgDTO dto : list) {
                for (SysUlDatCfgDtlDTO dtlDTO : dto.getSysUlDatCfgDtlDTOList()) {
                    vo = new PrjFileInfoVO();
                    if(StringUtils.isNotEmpty(condition.getPkId())){
                        vo.setId(Long.valueOf(condition.getPkId()));//业务主键
                    }
                    vo.setCfgDtlCd(dtlDTO.getCfgDtlCd());//配置子编号
                    vo.setDatNm(dtlDTO.getDatNm());//配置名称
                    vo.setCfgCd(dtlDTO.getCfgCd());//配置编号
                    vo.setOrgCd(dtlDTO.getOrgCd());//配置组织架构代码
                    vo.setCfgNm(dto.getCfgNm());//配置子名称
                    vo.setIsMust(dtlDTO.getIsMust());//是否必传
                    //如果有HTTP开头说明是可以访问路径,无需干涉
                    if(StringUtils.isNotBlank(dtlDTO.getFilePath()) && !dtlDTO.getFilePath().startsWith("http") && StringUtils.isNotBlank(picServicePath)){
                        vo.setFilePath(picServicePath+dtlDTO.getFilePath());
                    }else{
                        vo.setFilePath(dtlDTO.getFilePath());
                    }
                    vo.setFileId(dtlDTO.getRecId());
                    vo.setFileNm(dtlDTO.getRecFileNm());//上传名称               vo.setFileId(dtlDTO.getRecId());//附件ID
                    vo.setCrtTm(dtlDTO.getRecCrtTm());//上传时间
                    /*if(condition.getSysCd().equalsIgnoreCase(uploadSysCd)){
                        //如果有HTTP开头说明是可以访问路径,无需干涉
                        if(StringUtils.isNotBlank(dtlDTO.getFilePath()) && !dtlDTO.getFilePath().startsWith("http") && StringUtils.isNotBlank(picServicePath)){
                            vo.setFilePath(picServicePath+dtlDTO.getFilePath());
                        }else{
                            vo.setFilePath(dtlDTO.getFilePath());
                        }
                        vo.setFileNm(dtlDTO.getRecFileNm());//上传名称               vo.setFileId(dtlDTO.getRecId());//附件ID
                        vo.setCrtTm(dtlDTO.getRecCrtTm());//上传时间
                    }else{
                        if(CollectionUtils.isMapNotEmpty(regxUlFileRecMap)){
                            String key = dtlDTO.getCfgCd() +"_"+dtlDTO.getCfgDtlCd();
                            if(regxUlFileRecMap.containsKey(key)){
                                vo.setFilePath(regxUlFileRecMap.get(key).getFilePath());
                                vo.setFileNm(regxUlFileRecMap.get(key).getFileNm());//上传名称               vo.setFileId(dtlDTO.getRecId());//附件ID
                                vo.setCrtTm(regxUlFileRecMap.get(key).getCrtTm());//上传时间
                            }
                        }
                    }*/
                    if (StringUtils.isNotBlank(dtlDTO.getRecAudStsCd())) {
                        vo.setAudStsCd(dtlDTO.getRecAudStsCd());//验证状态
                    } else {
                        vo.setAudStsCd("0");//验证状态
                    }
                    if (audStsCdMap != null && audStsCdMap.containsKey(vo.getAudStsCd())) {
                        vo.setAudStsCdNm(audStsCdMap.get(vo.getAudStsCd()));
                    }
                    voList.add(vo);
                }
            }
        }
        return voList;
    }
    /**
	 * 发起供应商工商变更流程
	 */
	@RequestMapping(value = "/addSplGSApplyFlowStart.do", method = { RequestMethod.POST })
	@ResponseBody
    public Object addSplGSApplyFlowStart(HttpServletRequest request, HttpServletResponse response){
    	DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"供应商工商变更流程发起成功");
    	String splId = request.getParameter("splId");
    	if(StringUtils.isEmpty(splId)){
    		result.setSuccess(BaseConstant.IS_YESNO_NO);
    		result.setInfo("供应商ID为空，发起流程失败！");
    		return result ;
    	}
    	SysFlowSHQueryCondition condition = new SysFlowSHQueryCondition();
		condition.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_PASS);
		condition.setDataId(Long.valueOf(splId));
		condition.setBusTyp(FlowConstant.FLOW_MODEL_TYP_SPL_ACCESS);
		condition.setWordsInTheTable("SPL");
		condition.setSysCd(CurrentThreadContext.getCurrentSysCd());
		List<SysFlowSHDTO> searchFlowSHDTOList = this.flowApiService.searchFlowSHDTOList(condition );
		if(CollectionUtils.isEmpty(searchFlowSHDTOList)){
			result.setInfo("供应商未准入");
    		result.setSuccess(BaseConstant.IS_YESNO_NO);
    		return result ;
		}
    	boolean b1 = this.splBscInfoApplyService.checkSplGSFlowStatus(Long.valueOf(splId));

    	if(b1){
    		result.setInfo("禁止二次变更");
    		result.setSuccess(BaseConstant.IS_YESNO_NO);
    		return result ;
    	}

    	boolean isBasicChange = false ;//基本信息是否改变
    	boolean isRlPsnChange = false ;//法人信息是否改变
    	boolean isFrSole = false ;
    	List<SplRlPsnVO> frList = null ;
    	SplInfoVO splInfoVO = splInfoService.selectById(Long.valueOf(splId));
    	SplRlPsnQueryCondition qc = new SplRlPsnQueryCondition();
    	qc.setIsDel(BaseConstant.IS_YESNO_NO);
    	qc.setSplId(Long.valueOf(splId));
		List<SplRlPsnVO> rlPsnList = splRlPsnService.searchList(qc);
		if(CollectionUtils.isNotEmpty(rlPsnList)){
			frList = new ArrayList<>();
			for (SplRlPsnVO splRlPsnVO : rlPsnList) {
				if("1".equals(splRlPsnVO.getRlTypCd())){
					frList.add(splRlPsnVO);
				}
			}
		}
		if(splInfoVO != null){
			//HsjBasicDTO hsjBasicDTO = hsjQueryService.getCommInfoByNameAndType("1", splInfoVO.getSplNm());
			//查询配置
            SysCtrlCfgQueryCondition ctrlCondition = new SysCtrlCfgQueryCondition();
            ctrlCondition.setCtrlCode(SplSystemConstant.MANUAL_GS_APPLY_SEARCH_HSJ_INTERVAL);
            ctrlCondition.setSysCd(SplSystemConstant.SPL_SYS_CD);
            ctrlCondition.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
            String ctrlCode = this.sysCtrlCfgService.searchSysCtrlCfgByCtrlCode(ctrlCondition);
            long interval ;
            if (StringUtils.isEmpty(ctrlCode)) {
                interval = SplSystemConstant.MILLIS_FOR_24_HOURS;
            } else {
                interval = Long.parseLong(ctrlCode);
            }
            Date beforeInterval = new Date(new Date().getTime() - interval);
            HsjBasicDTO hsjBasicDTO = hsjQueryService.getCommInfoByNameAndTypeOnTime("1", splInfoVO.getSplNm(), beforeInterval, "MANUAL");

            if(hsjBasicDTO != null){
				if(StringUtils.isNotEmpty(hsjBasicDTO.getEntName()) && 
    					(!hsjBasicDTO.getEntName().equals(splInfoVO.getSplNm()))){
    				isBasicChange = true ;
    			}
    			if(StringUtils.isNotEmpty(hsjBasicDTO.getCreditCode()) &&
    					(!hsjBasicDTO.getCreditCode().equals(splInfoVO.getSucc()))){
    				isBasicChange = true ;
    			}
    			
    			if(StringUtils.isNotEmpty(hsjBasicDTO.getFrName())){
    				if(CollectionUtils.isNotEmpty(frList)){
    					if(frList.size() == 1){
    						isFrSole = true ;
    						if(!hsjBasicDTO.getFrName().equals(frList.get(0).getRlNm())){
    							isRlPsnChange = true ;
    						}
    					}else{
	    					/*for (SplRlPsnVO splRlPsnVO : frList) {
	    						if(hsjBasicDTO.getFrName().equals(splRlPsnVO.getRlNm())){
	    							flag = true ;
	    						}
							}*/
	    					//if(!flag){
    						isRlPsnChange = true ;
	    					//}
    					}
    				}else{
    					isRlPsnChange = true ;
    				}
    			}
    			if(isBasicChange || isRlPsnChange){
    				BaseLogUtils.newWebLogger("供应商信息与三方信息不一致，发起工商信息变更流程").setLogOperType(LogOperEnum.RESP)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                            .setWarning(false)
                            .info();

    				SplBscInfoApplyVO applyVO = new SplBscInfoApplyVO();
    				applyVO.setSplId(Long.valueOf(splId));
    				applyVO.setSplNmB(splInfoVO.getSplNm());
    				applyVO.setSplNm(hsjBasicDTO.getEntName());
    				applyVO.setSuccB(splInfoVO.getSucc());
    				applyVO.setSucc(hsjBasicDTO.getCreditCode());
    				applyVO.setIsChngBaseData(BaseConstant.IS_YESNO_YES);
    				applyVO.setIsValid(BaseConstant.IS_YESNO_YES);
    				applyVO.setStatus(BaseConstant.IS_YESNO_YES);
    				applyVO.setFlowTyp(BaseConstant.IS_YESNO_YES);
    				applyVO.setFlowStatus(BaseConstant.IS_YESNO_YES);
    				applyVO.setCstMgrOrgCd(CurrentThreadContext.getCurrentOrgCd());
    				applyVO.setCstMgrId(CurrentThreadContext.getCurrentUserId());
    				applyVO.setCstMgrNm(CurrentThreadContext.getCurrentUserName());
    				applyVO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
    				applyVO.setCrtTmB(splInfoVO.getCrtTm());
    				applyVO.setCrtTm(new Date());
    				applyVO.setMdfTmB(splInfoVO.getMdfTm());
    				applyVO.setMdfTm(new Date());
    				applyVO.setMdfUsrIdB(splInfoVO.getMdfUsrId());
    				applyVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
    				applyVO.setIsRecycleLoa(splInfoVO.getIsRecycleLoa());
    				applyVO.setIsRecycleLoaB(splInfoVO.getIsRecycleLoa());
    				applyVO.setIsUploadLoa(splInfoVO.getIsUploadLoa());
    				applyVO.setIsUploadLoaB(splInfoVO.getIsUploadLoa());
    				Long applyId = this.splBscInfoApplyService.addSplBscInfoApply(applyVO);
    				BaseLogUtils.newWebLogger("添加供应商变更主表信息成功，applyId="+applyId).setLogOperType(LogOperEnum.RESP)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                            .setWarning(false)
                            .info();
    				if(isRlPsnChange){
    					List<SplBiApplyRlPsnVO> applyRlPsnList = new ArrayList<>();
    					SplBiApplyRlPsnVO splBiApplyRlPsnVO = null ;
    					if(CollectionUtils.isNotEmpty(frList)){
	    					SplRlPsnVO splRlPsnVO = frList.get(0);
	    					splBiApplyRlPsnVO = new SplBiApplyRlPsnVO();
	    					splBiApplyRlPsnVO.setRlNm(hsjBasicDTO.getFrName());
	    					splBiApplyRlPsnVO.setRlNmB(splRlPsnVO.getRlNm());
	    					splBiApplyRlPsnVO.setSplRlPsnId(splRlPsnVO.getId());
	    					splBiApplyRlPsnVO.setRlTypCd(splRlPsnVO.getRlTypCd());
	    					splBiApplyRlPsnVO.setRlTypCdB(splRlPsnVO.getRlTypCd());
	    					splBiApplyRlPsnVO.setSplApplyId(applyId);
	    					splBiApplyRlPsnVO.setIsValid(BaseConstant.IS_YESNO_YES);
	    					splBiApplyRlPsnVO.setMdfTm(new Date());
	    					splBiApplyRlPsnVO.setMdfTmB(splRlPsnVO.getMdfTm());
	    					splBiApplyRlPsnVO.setMdfUsrIdB(splRlPsnVO.getMdfUsrId());
	    					splBiApplyRlPsnVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
	    					splBiApplyRlPsnVO.setCertTypCdB(splRlPsnVO.getCertTypCd());
	    					splBiApplyRlPsnVO.setCertTypCd(splRlPsnVO.getCertTypCd());
	    					splBiApplyRlPsnVO.setCertNoB(splRlPsnVO.getCertNo());
	    					splBiApplyRlPsnVO.setIsDelB(splRlPsnVO.getIsDel());
	    					splBiApplyRlPsnVO.setIsDel(splRlPsnVO.getIsDel());
	    					applyRlPsnList.add(splBiApplyRlPsnVO);
	    					frList.remove(0);
	    					if(CollectionUtils.isNotEmpty(frList)){
	    						for (SplRlPsnVO rlPsnVO : frList) {
	    							splBiApplyRlPsnVO = new SplBiApplyRlPsnVO();
	    	    					splBiApplyRlPsnVO.setRlNm(rlPsnVO.getRlNm());
	    	    					splBiApplyRlPsnVO.setRlNmB(rlPsnVO.getRlNm());
	    	    					splBiApplyRlPsnVO.setSplRlPsnId(rlPsnVO.getId());
	    	    					splBiApplyRlPsnVO.setRlTypCd(rlPsnVO.getRlTypCd());
	    	    					splBiApplyRlPsnVO.setRlTypCdB(rlPsnVO.getRlTypCd());
	    	    					splBiApplyRlPsnVO.setSplApplyId(applyId);
	    	    					splBiApplyRlPsnVO.setIsValid(BaseConstant.IS_YESNO_YES);
	    	    					splBiApplyRlPsnVO.setMdfTm(new Date());
	    	    					splBiApplyRlPsnVO.setMdfTmB(rlPsnVO.getMdfTm());
	    	    					splBiApplyRlPsnVO.setMdfUsrIdB(rlPsnVO.getMdfUsrId());
	    	    					splBiApplyRlPsnVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
	    	    					splBiApplyRlPsnVO.setCertTypCdB(rlPsnVO.getCertTypCd());
	    	    					splBiApplyRlPsnVO.setCertTypCd(rlPsnVO.getCertTypCd());
	    	    					splBiApplyRlPsnVO.setCertNoB(rlPsnVO.getCertNo());
	    	    					splBiApplyRlPsnVO.setIsDelB(rlPsnVO.getIsDel());
	    	    					splBiApplyRlPsnVO.setIsDel(BaseConstant.IS_YESNO_YES);
	    	    					applyRlPsnList.add(splBiApplyRlPsnVO);
								}
	    					}
    					}else{
    						splBiApplyRlPsnVO = new SplBiApplyRlPsnVO();
    						splBiApplyRlPsnVO.setRlNm(hsjBasicDTO.getFrName());
    						splBiApplyRlPsnVO.setRlTypCd("1");
    						splBiApplyRlPsnVO.setSplApplyId(applyId);
    						splBiApplyRlPsnVO.setIsValid(BaseConstant.IS_YESNO_YES);
    						splBiApplyRlPsnVO.setMdfTm(new Date());
    						splBiApplyRlPsnVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
    						splBiApplyRlPsnVO.setCertTypCd("0");
    						splBiApplyRlPsnVO.setIsDel(BaseConstant.IS_YESNO_NO);
    						applyRlPsnList.add(splBiApplyRlPsnVO);
    					}
    					BaseLogUtils.newWebLogger("添加主要联系人变更信息，data："+JSON.toJSONString(applyRlPsnList)).setLogOperType(LogOperEnum.RESP)
                                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                                .setWarning(false)
                                .info();
    					this.splBscInfoApplyService.saveBiApplyRlPsn(applyRlPsnList, applyId);
    				}

    				// 当前供应商是否在变更中
    				boolean b = this.splBscInfoApplyService.checkFlowStatus(Long.valueOf(splId), WebBaseConstant.SYS_SYS_CD, WebBaseConstant.SYS_P_ORG_CD);
    		    	if(b){
    					// 当前供应商在变更中，不发起工商变更流程
    					result.setInfo("当前供应商在变更中，不发起工商变更流程！");
    					SplBscInfoApplyVO entity = new SplBscInfoApplyVO();
						entity.setId(applyId);
						entity.setFlowStatus(BaseConstant.IS_YESNO_NO);
						this.splBscInfoApplyService.saveBscInfoApply(entity);
    					return result;
    		    	}
					// 当前供应商不在变更中，发起工商变更流程
					FlowStartedDTO flowStartDTO = this.addSplGsApplyFlowStart(applyId,Long.valueOf(splId));

					if(flowStartDTO == null){
						SplBscInfoApplyVO entity = new SplBscInfoApplyVO();
						entity.setId(applyId);
						entity.setFlowStatus(BaseConstant.IS_YESNO_NO);
						this.splBscInfoApplyService.saveBscInfoApply(entity);
						result.setInfo("流程发起失败！");
						result.setSuccess(BaseConstant.IS_YESNO_NO);
					}
    			}else{
    				result.setInfo("供应商信息与三方信息一致！");
    			}
			}else{
				result.setInfo("未查询到供应商的工商信息！");
			}
		}
    	return result ;
    }
	
	private FlowStartedDTO addSplGsApplyFlowStart(Long applyId,Long splId){
		

        //String procDefKey = request.getParameter("procDefKey");
        //String procDefId = request.getParameter("procDefId");
        //String procNo = request.getParameter("procNo");
        FlowStartParamsDTO flowStartParamsDTO = new FlowStartParamsDTO();
        Map<String, Object> startParams = new HashMap<>();
        startParams.put("verifierId", CurrentThreadContext.getCurrentUserId());
        try{
        	Map<Long, String> selectPrjOrgCdByDataId = this.splDataStatisticsApiService.selectPrjOrgCdByDataId(splId, "SPL");
        	startParams.put("isFlowTyp", 1);
        	if(CollectionUtils.isMapNotEmpty(selectPrjOrgCdByDataId)){
        		Set<Long> keySet = selectPrjOrgCdByDataId.keySet();
        		String orgCd = null ;
        		Long cstMgrId = null ;
        		for (Long long1 : keySet) {
        			cstMgrId = long1 ;
        			orgCd = selectPrjOrgCdByDataId.get(long1);
        		}
        		startParams.put("verifierId", cstMgrId);
        	}
        }catch(BaseException be){
            BaseLogUtils.newWebLogger("查询项目发起人失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(be)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        }catch(Exception ex){
            BaseLogUtils.newWebLogger("查询项目发起人失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        try {
        	SysFlowManageVQueryCondition qc = new SysFlowManageVQueryCondition();
			qc.setModelTyp("038");
			qc.setSysCd(SplSystemConstant.FL_SYS_CD);
			qc.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
			//qc.setProcDefKey(WebBaseConstant.FLOW_MODEL_TYP_SPL_GS_CHG);
	        List<SysFlowManageVVO> list = this.flowService.searchFlowManageVListForStart(qc);
	        if(CollectionUtils.isNotEmpty(list)){
        	
            //流程定义Key和流程定义ID 如果是前端选择的则直接指定,如果不是则系统自动按照配置选择唯一一条记录,如果找不到会提示
            flowStartParamsDTO.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_IN);

            flowStartParamsDTO.setWordsInTheTable(SplInfoConstant.SPL_FLOW_S_H_SPL);
            //流程定义标识(必填)
            flowStartParamsDTO.setProcDefKey(list.get(0).getProcDefKey());
            //流程定义ID(必填)
            flowStartParamsDTO.setProcDefId(list.get(0).getProcDefId());
            //流程定义名称(自定义)
            flowStartParamsDTO.setProcNo(list.get(0).getProcNo());

            flowStartParamsDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
            //业务数据主键(必填)
            flowStartParamsDTO.setBusinessKey(applyId + "");
            flowStartParamsDTO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
            flowStartParamsDTO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
            flowStartParamsDTO.setSysCd(CurrentThreadContext.getCurrentSysCd());
            flowStartParamsDTO.setInitiator(String.valueOf(CurrentThreadContext.getCurrentUserId()));
            flowStartParamsDTO.setInitiatorNm(CurrentThreadContext.getCurrentUserName());
            flowStartParamsDTO.setProcPriority(FlowConstant.FLOW_PRIORITY_EMERGENCY);//优先级,可以在界面定义
            //业务类型(必填)-用于区分操作表标识
            flowStartParamsDTO.setBusinessType(FlowConstant.FLOW_BUSINESS_TYP_SPL_BSC_INFO);//确认用不用
            //模块类型(流程业务分类): 针对直接启动流程的业务使用
            flowStartParamsDTO.setModelTyp(FlowConstant.FLOW_MODEL_TYP_SPL_CHG);//需要和流程配置中的模块类型匹配
            flowStartParamsDTO.setStartParams(startParams);
            flowStartParamsDTO.setSearchDesc(CurrentThreadContext.getCurrentOrgDispNm() + "、供应商信息变更流程大字段参数未定!");
            DataResultDTO dataResultDTO = this.splBscInfoApplyService.addSplApplyFlowStart(flowStartParamsDTO);
            if (null != dataResultDTO && null != dataResultDTO.getData()) {
                FlowStartedDTO flowStartedDTO = (FlowStartedDTO) dataResultDTO.getData();
                return flowStartedDTO;
            }
	        }
        } catch (BaseException e) {
        	SplBscInfoApplyVO entity = new SplBscInfoApplyVO();
			entity.setId(applyId);
			entity.setFlowStatus(BaseConstant.IS_YESNO_NO);
			this.splBscInfoApplyService.saveBscInfoApply(entity);
            BaseLogUtils.newWebLogger("发起工商变更流程失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            e.getStackTrace();
        } catch (Exception e) {
        	SplBscInfoApplyVO entity = new SplBscInfoApplyVO();
			entity.setId(applyId);
			entity.setFlowStatus(BaseConstant.IS_YESNO_NO);
			this.splBscInfoApplyService.saveBscInfoApply(entity);
            BaseLogUtils.newWebLogger("发起工商变更流程失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
            e.getStackTrace();
        }
        return null;
    
	}
	
	/**
	 * 发起供应商工商变更流程
	 */
	@RequestMapping(value = "/toDeadStartFlowList.do", method = { RequestMethod.POST ,RequestMethod.GET})
	@ResponseBody
	public ModelAndView toDeadStartFlowList(HttpServletRequest request, HttpServletResponse response) throws BaseException{
		ModelAndView view = new ModelAndView("product/splInfo/deadStartFlowListPage");
		
		return view ;
	}
    /**
	 * 变更流程发起失败列表
	 */
	@RequestMapping(value = "/deadStartFlowList.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object deadStartFlowList(HttpServletRequest request, HttpServletResponse response) throws BaseException{
		String dataName = request.getParameter("dataName");//企业名称
		String dataType = request.getParameter("dataType");//企业类型
		String audStsCd = request.getParameter("audStsCd");//审核状态
		String rgnPrCd = request.getParameter("rgnProvCd");//区域-省
		String rgnCyCd = request.getParameter("rgnCityCd");//区域-市
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pageSize");
		Pager page = new Pager();
		Pager pager = null ;
		if(StringUtils.isNotEmpty(currentPage)){
			page.setCurrentPage(Integer.valueOf(currentPage));
		}
		if(StringUtils.isNotEmpty(pageSize)){
			page.setEveryPage(Integer.valueOf(pageSize));
		}
		if(StringUtils.isNotEmpty(dataType) && dataType.equals("2")){
			//PrjLnkCompApplyQueryCondition compApplyQueryCondition = new PrjLnkCompApplyQueryCondition();
			LnkCompModQC lnkCompModQC = new LnkCompModQC();
			lnkCompModQC.setFlowTyp(BaseConstant.IS_YESNO_YES);
			lnkCompModQC.setFlowStatus(BaseConstant.IS_YESNO_NO);
			if(StringUtils.isNotEmpty(rgnPrCd)){
				lnkCompModQC.setRgnPrCd(rgnPrCd);
			}
			if(StringUtils.isNotEmpty(rgnCyCd)){
				lnkCompModQC.setRgnCyCd(rgnCyCd);
			}
			if(StringUtils.isNotEmpty(dataName)){
				lnkCompModQC.setLnkCompNm(dataName);
			}
			page.setCondition(lnkCompModQC);
			pager = this.lnkCompModService.searchChangeListPage(page);
			return new ListPageVO<>(pager.getResultList(), pager.getTotalCount());
		}else{
			SplBscInfoApplyQC splBscInfoApplyQC = new SplBscInfoApplyQC();
			splBscInfoApplyQC.setFlowTyp(BaseConstant.IS_YESNO_YES);
			splBscInfoApplyQC.setFlowStatus(BaseConstant.IS_YESNO_NO);
			//splBscInfoApplyQC.set
			if(StringUtils.isNotEmpty(dataName)){
				splBscInfoApplyQC.setSplNm(dataName);
			}
			if(StringUtils.isNotEmpty(rgnPrCd)){
				splBscInfoApplyQC.setRgnPrCd(rgnPrCd);
			}
			if(StringUtils.isNotEmpty(rgnCyCd)){
				splBscInfoApplyQC.setRgnCyCd(rgnCyCd);
			}
			page.setCondition(splBscInfoApplyQC);
			BaseLogUtils.newWebLogger("查询保存未发起流程的记录，page:"+JSON.toJSONString(page)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();

			pager = this.splBscInfoApplyService.searchSplApplyListPage(page);
			
			List<SplBscInfoApplyVO> resultList = (List<SplBscInfoApplyVO>)pager.getResultList();
			List<JSONObject> rows = new ArrayList<>();
			if(CollectionUtils.isNotEmpty(resultList)){
				List<Long> splIds = new ArrayList<>();
				for (SplBscInfoApplyVO vo : resultList) {
					splIds.add(vo.getSplId());
				}
				SplInfoQueryCondition condition = new SplInfoQueryCondition();
				condition.setIds(splIds);
				List<SplInfoVO> searchList = this.splInfoService.searchList(condition );
				Map<Long, String> splIdToAttrCdMap = new HashMap<>();
				for (SplInfoVO splInfoVO : searchList) {
					splIdToAttrCdMap.put(splInfoVO.getId(), splInfoVO.getSplAttrCd());
				}
				JSONObject obj ;
				for (SplBscInfoApplyVO vo : resultList) {
					obj = new JSONObject();
					obj.put("dataId", vo.getId());
					obj.put("dataName", vo.getSplNmB());
					obj.put("succ", vo.getSuccB());
					String string = splIdToAttrCdMap.get(vo.getSplId());
					obj.put("attrCd", splIdToAttrCdMap.get(vo.getSplId()));
					if("2".equals(string)){
						obj.put("attrCdNm", "法人");
					}else{
						obj.put("attrCdNm", "自然人");
					}
					if(StringUtils.isNotEmpty(dataType)){
						obj.put("dataType", dataType);
					}else{
						obj.put("dataType", 1);
					}
					obj.put("audStsCdNm", "审核通过");
					obj.put("splId", vo.getSplId());
					rows.add(obj);
				}
			}
			return new ListPageVO<>(rows, pager.getTotalCount());
		}
	}

	/**
	 * 变更流程发起失败列表
	 */
	@RequestMapping(value = "/againAddFlowStart.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object againAddFlowStart(HttpServletRequest request, HttpServletResponse response) throws BaseException{
		String applyId = request.getParameter("applyId");
		String splId = request.getParameter("splId");

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"发起供应商工商变更流程成功！");
		if(StringUtils.isEmpty(applyId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("供应商变更主表ID为空，发起失败！");
			return result ;
		}
		try{
			// 当前供应商是否在变更中
	    	boolean b = this.splBscInfoApplyService.checkFlowStatus(Long.valueOf(splId), WebBaseConstant.SYS_SYS_CD, WebBaseConstant.SYS_P_ORG_CD);
	    	if(b){
				result.setInfo("当前供应商在变更中，不发起工商变更流程！");
				SplBscInfoApplyVO entity = new SplBscInfoApplyVO();
				entity.setId(Long.valueOf(applyId));
				entity.setFlowStatus(BaseConstant.IS_YESNO_NO);
				this.splBscInfoApplyService.saveBscInfoApply(entity);
				return result;
	    	}
			FlowStartedDTO addSplGsApplyFlowStart = this.addSplGsApplyFlowStart(Long.valueOf(applyId),Long.valueOf(splId));

			if(addSplGsApplyFlowStart != null){
				SplBscInfoApplyVO entity = new SplBscInfoApplyVO();
				entity.setId(Long.valueOf(applyId));
				entity.setFlowStatus(BaseConstant.IS_YESNO_YES);
				this.splBscInfoApplyService.saveBscInfoApply(entity);
				result.setInfo("流程发起成功！");
				result.setSuccess(BaseConstant.IS_YESNO_YES);
			}else{
				result.setInfo("流程发起失败！");
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				}
		}catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("重新发起工商变更流程失败！");
            BaseLogUtils.newWebLogger("再次发起工商变更流程失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("重新发起工商变更流程失败！");
            BaseLogUtils.newWebLogger("再次发起工商变更流程失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
		return result ;
	}

    /**
     * 设置页面字符串数据
     * @param list
     * @return
     */
    private String listTransferToString(List<?> list){
        StringBuilder sb = new StringBuilder();
        if (CollectionUtils.isNotEmpty(list)) {
            for (int i = 0; i < list.size(); i++) {
                if (i < list.size() - 1) {
                    sb.append(list.get(i) + ";");
                } else {
                    sb.append(list.get(i));
                }
            }
        }
        return sb.toString();
    }
}